I have been given an assignment to design and program a calculator using C++ and Ultimate ++IDE(Integrated development Environment). My code should have a class Calculator as a base class, and another class scientificCalculator which inherits from class Calculator. The Calculator class performs basic arithmetic operations. The scientificCalculator adds more operations, and is able to compute Sine, Cosine, Tangent, Logarithm and Exponential computations. Please can someone come to my rescue because I have to submit by the 22nd November 2009.

Edited 7 Years Ago by masapo: I missed some information

masapo...

i cannot see any problem with this...
seem you already knew that how to declare the class and build the object and so on...
is that you have any problem about how to write the code?
If you got the problem in your coding..
you suppose to show your code first,so that the others could help you....

#include<iostream.h>
#include<math.h>
#include<stdio.h>
#include<conio.h>
void main(){
clrscr();
long double a,b,sum,sub,mul,div,sqr,sqr2,cub,cub2=0;
float cs,cs2,tn,tn2,sn,sn2=0;
int c=0;
cout<<"ENTER THE 1ST NUM :";
cin>>a;
cout<<"\nENTER THE 2nd NUM :";
cin>>b;
cout<<"******************MENU******************";
sum=a+b;
sub=a-b;
mul=a*b;
div=a/b;
sqr=a*a;
sqr2=b*b;
cub=a*a*a;
cub2=b*b*b;
cs=cos(a);
cs2=cos(b);
sn=sin(a);
sn2=sin(b);
tn=tan(a);
tn2=tan(b);
cout<<"\nEnter 1  For Addition";
cout<<"\nEnter 2  For Subtraction";
cout<<"\nEnter 3  For Multiplication";
cout<<"\nEnter 4  For Division";
cout<<"\nEnter 5  For SQUARE Of 1st Value";
cout<<"\nEnter 6  For SQUARE Of 2nd Value";
cout<<"\nEnter 7  For CUBE Of 1st Value";
cout<<"\nEnter 8  For CUBE Of 2nd Value";
cout<<"\nEnter 9  For Tan Of 1st Value";
cout<<"\nEnter 10 For Tan Of 2nd Value";
cout<<"\nEnter 11 For COS Of 1st Value";
cout<<"\nEnter 12 For COS Of 2nd Value";
cout<<"\nEnter 13 For SIN Of 1st Value";
cout<<"\nEnter 14 For SIN Of 2nd Value\n";
cin>>c;
switch(c){
case 1:
cout<<"\nAddition of "<< a<<" and "<<b <<" is ="<<sum;
break;
case 2:
cout<<"\nSUBTRACTION of "<<a <<" and " <<b<<" is = "  <<sub;
break;
case 3:
cout<<"\nMULTIPLICATION:"<<mul;
break;
case 4:
cout<<"\nDIVISION:"<<div;
break;
case 5:
cout<<"\nSQUARE OF 1ST VALUE:"<<sqr;
break;
case 6:
cout<<"\nSQUARE OF 2ND VALUE:"<<sqr2;
break;
case 7:
cout<<"\nCUBE OF 1ST VALUE:"<<cub;
break;
case 8:
cout<<"\nCUBE OF 2ND VALUE:"<<cub2;
break;
case 9:
cout<<"\nTAN OF 1ST VALUE:"<<tn;
break;
case 10:
cout<<"\nTAN OF 2ND VALUE:"<<tn2;
break;
case 11:
cout<<"\nCOS OF 1ST VALUE:"<<cs;
break;
case 12:
cout<<"\nCOS OF 2ND VALUE:"<<cs2;
break;
case 13:
cout<<"\nSIN OF 1ST VALUE:"<<sn;
break;
case 14:
cout<<"\nSIN OF 2ND VALUE:"<<sn2;
break;}
getch();}

made by: Fahad

Edited 6 Years Ago by __avd: Added [code] tags. Encase your code in: [code] and [/code]

>made by: Fahad
You shouldn't admit to writing code like that.

In this style every one can understand easily!!

You need to indent your code. You cannot possibly expect us to read that unreadable code mess!

Encase your code in:

[code] and

[/code]
tags.

In this style every one can understand easily!!

And with everyone, you probably mean: no-one. Learn about indenting code. Not to mention the use of clrscr(), void main(), conio, etc etc

>In this style every one can understand easily!!
You're absolutely right. Everyone can easily understand that you're a horrible programmer whose advice should be ignored.

This article has been dead for over six months. Start a new discussion instead.