Kalkulator
//---------------------------------------------------------------------------
#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)
{
float a,b,wynik;
a=StrToFloat(Edit1->Text);
b=StrToFloat(Edit2->Text);
if (RadioButton1->Checked) wynik=a+b;
if (RadioButton2->Checked) wynik=a-b;
if (RadioButton3->Checked) wynik=a*b;
if (RadioButton4->Checked) wynik=a/b;
Edit3->Text=FloatToStr(wynik);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit3Change(TObject *Sender)
{
Edit3->Text=IntToStr(StrToInt(Edit1->Text)+StrToInt(Edit2->Text));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1Change(TObject *Sender)
{
if (Edit1->Text==”0”) Edit1->Text=””;
}
//---------------------------------------------------------------------------