Professional Documents
Culture Documents
21)
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
TForm1 *Form1;
//---------------------------------------------------------------------------
: TForm(Owner)
//---------------------------------------------------------------------------
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)
TForm1 *Form1;
//---------------------------------------------------------------------------
: TForm(Owner)
//---------------------------------------------------------------------------
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)
TForm1 *Form1;
//---------------------------------------------------------------------------
: TForm(Owner)
//---------------------------------------------------------------------------
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)
TForm1 *Form1;
//---------------------------------------------------------------------------
: TForm(Owner)
//---------------------------------------------------------------------------
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);
//---------------------------------------------------------------------------
Edit1->Clear();
Edit2->Clear();
Edit3->Clear();
//---------------------------------------------------------------------------
(5.23)
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
TForm1 *Form1;
//---------------------------------------------------------------------------
: TForm(Owner)
//---------------------------------------------------------------------------
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));
}
y = 0;
if (x > 2.0) {
y = sqrt (fabs(1.0-x));
Edit2->Text = FloatToStr(y);
//---------------------------------------------------------------------------