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);
}
//---------------------------------------------------------------------------

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.