You are on page 1of 7

(2.

21)

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

double n1, n2, n3, p1, p2, p3, m;

n1 = StrToFloat(Edit1->Text);

n2 = StrToFloat(Edit2->Text);

n3 = StrToFloat(Edit3->Text);

p1 = StrToFloat(Edit4->Text);

p2 = StrToFloat(Edit5->Text);

p3 = StrToFloat(Edit6->Text);

m = (n1*p1+n2*p2+n3*p3)/(p1+p2+p3);

Edit7->Text= FloatToStr(m);
}

(2.46)

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

double r, a, A, V;

r = StrToFloat(Edit1->Text);

a = StrToFloat(Edit2->Text);

V = (2.0/3.0)*pow(r,3.0)*a;

A = (2.0*pow(r,2.0)*a)+(M_PI*pow(r,2.0));

Edit3->Text = FloatToStr(A);

Edit4->Text = FloatToStr(V);
}

//---------------------------------------------------------------------------

(2.49)

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

double r, a, b, h, Am, A0, V;

r = StrToFloat(Edit1->Text);

a = StrToFloat(Edit2->Text);

b = StrToFloat(Edit3->Text);

h = StrToFloat(Edit4->Text);

Am = 2.0*M_PI*r*h;
A0 = M_PI*((2*r*h)+pow(a,2.0)+pow(b,2.0));

V = (1.0/6.0)*M_PI*h*((3.0*pow(a,2.0))+(3.0*pow(b,2.0))+pow(h,2.0));

Edit5->Text = FloatToStr(Am);

Edit6->Text = FloatToStr(A0);

Edit7->Text = FloatToStr(V);

//---------------------------------------------------------------------------

(5.9)

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

double a, b, c, menor;
a = StrToFloat(Edit1->Text);

b = StrToFloat(Edit2->Text);

c = StrToFloat(Edit3->Text);

if (a < b) {

if (a < c)

menor = a;

else

menor = c;

else

if (b < c) {

menor = b; }

else

menor = c;

Edit4->Text = FloatToStr(menor);

//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)

Edit1->Clear();

Edit2->Clear();

Edit3->Clear();

//---------------------------------------------------------------------------
(5.23)

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

double x, y;

x = StrToFloat(Edit1->Text);

if (x == 2.0 || x == -2.0) {

Edit2->Text = "ERRO!";

else

if (x < -2.0) {

y = sqrt(fabs(x+1.0));
}

if (x > -2.0 && x < 2.0) {

y = 0;

if (x > 2.0) {

y = sqrt (fabs(1.0-x));

Edit2->Text = FloatToStr(y);

//---------------------------------------------------------------------------

You might also like