0

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.

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

#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);
}
//---------------------------------------------------------------------------
2
Contributors
1
Reply
5
Views
6 Years
Discussion Span
Last Post by CppBuilder2006
0

but the code you put, is a Borland's VCL code. it's not a Visual C++ code!
but I think programming with Borland's C++Builder is easier! ;)
about arctan, etc there are appropriate functions in math.h

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.