Hi to all,
THis is my first post here.
I have a project to create a scientific calculator.
i wrote a code and i need some help on how to proceed.
The code i wrote is for +, - , * , /
now i want to continue with x^y, arc,tan etc.
any ideas on how to proceed with these?
Thanks in advance.
Code://--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" #include "Unit2.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" BOOL IsNumber(AnsiString s) { int i; BOOL itis=true; for (i=1 ; i<=s.Length() ; i++) if (!isdigit(s[i]) && s[i]!=',' && s[i]!='-') itis=false; return itis; } TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button11Click(TObject *Sender) { Form1 -> Close(); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button9Click(TObject *Sender) { Edit1 -> Clear(); Edit2 -> Clear(); Edit3 -> Clear(); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button10Click(TObject *Sender) { Form2 -> ShowModal(); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { if (IsNumber(Edit1->Text) && IsNumber(Edit2->Text)) Edit3->Text=Edit1->Text.ToDouble() + Edit2->Text.ToDouble(); else MessageBox(NULL,"Not a number", "About Form",MB_OK|MB_ICONSTOP); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { if (IsNumber(Edit1->Text) && IsNumber(Edit2->Text)) Edit3->Text=Edit1->Text.ToDouble() - Edit2->Text.ToDouble(); else MessageBox(NULL,"Not a number", "About Form",MB_OK|MB_ICONSTOP); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button3Click(TObject *Sender) { if (IsNumber(Edit1->Text) && IsNumber(Edit2->Text)) Edit3->Text=Edit1->Text.ToDouble() * Edit2->Text.ToDouble(); else MessageBox(NULL,"Not a number", "About Form",MB_OK|MB_ICONSTOP); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button4Click(TObject *Sender) { if (IsNumber(Edit1->Text) && IsNumber(Edit2->Text)) Edit3->Text=Edit1->Text.ToDouble() / Edit2->Text.ToDouble(); else MessageBox(NULL,"Not a number", "About Form",MB_OK|MB_ICONSTOP); } //---------------------------------------------------------------------------



LinkBack URL
About LinkBacks



