//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "math.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int t=0;
String s;
double S;
double fs;
double is;
bool k=false;
bool z=false;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button17Click(TObject *Sender)
{
s=StaticText1->Caption;
if(StaticText1->Caption!=""){
if(!k)
{
s=s+".";
k=true;
StaticText1->Caption=s;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button16Click(TObject *Sender)
{
StaticText1->Caption="";
k=false; z=false;
fs=0; is=0; t=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button11Click(TObject *Sender)
{
k=false; z=false;
switch ( t )
{
case 0: {fs = StrToFloat (StaticText1->Caption); StaticText1->Caption="";} break;
case 1: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); fs=fs+is; StaticText1->Caption="";} break;
case 2: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); fs=fs-is; StaticText1->Caption="";} break;
case 3: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); fs=fs*is; StaticText1->Caption="";} break;
case 4: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); if (is!=0) fs=(double)fs/is; else StaticText1->Caption="Error"; StaticText1->Caption="";} break;
}
t=1 ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button12Click(TObject *Sender)
{
k=false; z=false;
switch ( t )
{
case 0: {fs = StrToFloat (StaticText1->Caption); StaticText1->Caption="";} break;
case 1: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); fs=fs+is; StaticText1->Caption="";} break;
case 2: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); fs=fs-is; StaticText1->Caption="";} break;
case 3: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); fs=fs*is; StaticText1->Caption="";} break;
case 4: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); if (is!=0) fs=(double)fs/is; else StaticText1->Caption="Error"; StaticText1->Caption="";} break;
}
t=2;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button13Click(TObject *Sender)
{
k=false; z=false;
switch ( t )
{
case 0: {fs = StrToFloat (StaticText1->Caption); StaticText1->Caption="";} break;
case 1: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); fs=fs+is; StaticText1->Caption="";} break;
case 2: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); fs=fs-is; StaticText1->Caption="";} break;
case 3: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); fs=fs*is; StaticText1->Caption="";} break;
case 4: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); if (is!=0) fs=(double)fs/is; else StaticText1->Caption="Error"; StaticText1->Caption="";} break;
}
t=3;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button14Click(TObject *Sender)
{
k=false; z=false;
switch ( t )
{
case 0: {fs = StrToFloat (StaticText1->Caption); StaticText1->Caption="";} break;
case 1: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); fs=fs+is; StaticText1->Caption="";} break;
case 2: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); fs=fs-is; StaticText1->Caption="";} break;
case 3: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); fs=fs*is; StaticText1->Caption="";} break;
case 4: if (StaticText1->Caption!="") {is = StrToFloat (StaticText1->Caption); if (is!=0) fs=(double)fs/is; else StaticText1->Caption="Error"; StaticText1->Caption="";} break;
}
t=4;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
s=StaticText1->Caption;
s=s+((TButton*) Sender)->Caption;
StaticText1->Caption=s;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button15Click(TObject *Sender)
{
if (!z){
is = StrToFloat (StaticText1->Caption);
z=true;}
StaticText1->Caption="";
switch ( t ) {
case 1: fs=fs+is; break;
case 2: fs=fs-is; break;
case 3: fs=fs*is; break;
case 4: {if (is!=0) fs=(double)fs/is; else StaticText1->Caption="Error"; break;}
}
StaticText1->Caption=FloatToStr(fs);
k=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button18Click(TObject *Sender)
{
s=StaticText1->Caption;
S=StrToFloat(s);
S=-S;
s=FloatToStr(S);
StaticText1->Caption=s;
}
//---------------------------------------------------------------------------