Topshiriq: C++da kakkulyator yaratish


Download 39.36 Kb.
Sana03.12.2020
Hajmi39.36 Kb.
#157537
Bog'liq
С Builder 1-dedline


Guruh

F.I.SH

Baho

640-19

Umarov Husanboy




Topshiriq:C++da kakkulyator yaratish.

Button-buyuruq tugmasi (obrabotchik sobitini OnKCick).Bu kompanenta dasturchi tomonidan berrilgan buyuriqlarnibajarishda ishlatiladi

Label-Metka (belgi).Bu bu kompanenta forma oynasi uchun uzun bolmagan bir qatorli yozuvni chiqarishda ishlatiladi va uning piktagrammasida “A” ko’rinishda beriladi.

Edit- Kirish qatori. Forma oynasida matinli qator kiritish va taxrirlashda ishlatiladi

Panel-Panel. Bu Kopanenta.Huddi GroupBoxga o’zshash kompanenalarni birlshtirish uchun xizmat qiladi.

#include

#pragma hdrstop

#include "Unit1.h"

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

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

Double a,c,b,d ,s=0;

int amal;

bool rost=true,we=true;

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

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}



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

void __fastcall TForm1::SpeedButton11Click(TObject *Sender)

{ if(ekran->Caption=="0" || rost==true)

ekran->Caption="";

ekran->Caption=ekran->Caption+((TButton*)Sender)->Caption;

rost=false;

}

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



void __fastcall TForm1::SpeedButton9Click(TObject *Sender)

{

amal=1;



a=StrToFloat(ekran->Caption);

rost=true;

}

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



void __fastcall TForm1::SpeedButton1Click(TObject *Sender)

{ String e;

e=ekran->Caption;

if(e.Length()>=15)

{ShowMessage("bu dastur 15 razilyadli sonlar ustida ishlay oladi");

ekran->Caption="0";return;};

switch(amal)

{case 1: b=StrToFloat(ekran->Caption); c=b+a;ekran->Caption=FloatToStr(c); break;

case 2: b=StrToFloat(ekran->Caption);c=a-b;ekran->Caption=FloatToStr(c);rost=true; break;

case 3: b=StrToFloat(ekran->Caption);c=a*b;ekran->Caption=FloatToStr(c);rost=true;break;

case 4: b=StrToFloat(ekran->Caption);if(b==0){ekran->Caption="Mavhum holat";break;}

else c=a/b;ekran->Caption=FloatToStr(c);rost=true;break;

}

}

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



void __fastcall TForm1::SpeedButton18Click(TObject *Sender)

{

ekran->Caption="0";



}

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

void __fastcall TForm1::SpeedButton5Click(TObject *Sender)

{

amal=2;



a=StrToFloat(ekran->Caption);

rost=true;

}

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



void __fastcall TForm1::SpeedButton6Click(TObject *Sender)

{

amal=3;



a=StrToFloat(ekran->Caption);

rost=true;

}

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



void __fastcall TForm1::SpeedButton19Click(TObject *Sender)

{

amal=4;



a=StrToFloat(ekran->Caption);

rost=true;

}

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



void __fastcall TForm1::SpeedButton13Click(TObject *Sender)

{

ekran->Caption=FloatToStr(StrToFloat(ekran->Caption)*(-1)) ;



}

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

void __fastcall TForm1::SpeedButton17Click(TObject *Sender)

{

String s;



s=ekran->Caption;

s.Delete(s.Length(),1);

ekran->Caption=s;

if(s.Length()<1)ekran->Caption="0";

}

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



void __fastcall TForm1::SpeedButton20Click(TObject *Sender)

{ float w;

a=StrToFloat(ekran->Caption); if(a==0){ekran->Caption="Mavhum holat";return ;}

w=1./a; ekran->Caption=FloatToStr(w);rost=true ;

}

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



void __fastcall TForm1::SpeedButton8Click(TObject *Sender)

{ String w;

w=ekran->Caption;if(w.Pos(",")==0)

{ekran->Caption=ekran->Caption+((TButton*)Sender)->Caption;rost=false; }else {rost=false;};

}

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



void __fastcall TForm1::SpeedButton21Click(TObject *Sender)

{

float z,c;



z=StrToFloat(ekran->Caption);

ekran->Caption=FloatToStr(pow(z,1./2));

we=true;

}

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



void __fastcall TForm1::SpeedButton23Click(TObject *Sender)

{ float q;

if(!SpeedButton23->OnMouseDown && we)

{q=StrToFloat(ekran->Caption);

ekran->Caption=(FloatToStr(q/100));;};}

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

void __fastcall TForm1::SpeedButton24Click(TObject *Sender)

{ int w=1,s;

s=StrToInt(ekran->Caption) ;

if(s>0) {for(int i=1;i<=s;i++){ w=w*i;} };

if(s==0){ w=1;}

if(s<0){ekran->Caption="mavjud emas";return;}

ekran->Caption=IntToStr(w);}

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

void __fastcall TForm1::SpeedButton22Click(TObject *Sender)

{float w;

w=StrToFloat(ekran->Caption);w=w*w;

ekran->Caption=FloatToStr(w);}



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

Download 39.36 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling