05-09-2016, 04:45 PM
/*it is a calculator which can perform 23 functions.
it is a project given by a Great teacher Sir Irfan Iffi
at the University of Punjab Gujranwala Campus Pakistan
I'm sohail Ahmad
... keep enjoy this calculator!!! Have a good Day!*/
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
void main()
{
clrscr();
while(1)
{
cout<<"\t\tUNIVERSITY OF PUNJAB"<<endl;
cout<<"\t\tGUJRANWALA CAMPUS"<<endl;
cout<<"Sohail Ahmad"<<endl;
cout<<"ROLL NO : BT15308"<<endl;
cout<<"______________________________"<<endl;
cout<<"\t\tSCIENTIFIC CALCULATOR"<<endl<<endl;
cout<<"*"<<endl<<endl;
cout<<"Press The Following Buttons:"<<endl;
cout<<" 1-For Addition 2-For Subtraction "<<endl;
cout<<" 3-For Multiplication 4-For Division "<<endl;
cout<<" 5-For logarithem 6-For sin "<<endl;
cout<<" 7-For cosine 8-For tan "<<endl;
cout<<" 9-For power 10-For square root "<<endl;
cout<<" 11-For Area of Triangle 12-For Voume of triangle "<<endl;
cout<<" 13-For Area of Rectangle 14-For Volume of Rectangle "<<endl;
cout<<" 15-For Area of Circle 16-For Circumference of Circle "<<endl;
cout<<" 17_For Vf=Vi+at 18-For S=Vit+1/2at*t "<<endl;
cout<<" 19-For S=v*t 20-For f=m*a "<<endl;
cout<<" 21-For d=m/t 22-For Temp. In farenheit "<<endl;
cout<<" 23-For Temp. In Celsius 24-For Exit "<<endl;
int a;
cout<<"\t\tEnter Your Choice : ";
cin>>a;
switch(a)
{
case 1:
clrscr();
int b,c,sum;
cout<<"\tADD TWO NUMBERS"<<endl;
cout<<"----------------------------"<<endl;
cout<<"Enter 1st Number : ";
cin>>b;
cout<<"Enter 2nd Number : ";
cin>>c;
sum=b+c;
cout<<"Sum Is : "<<sum<<endl;
break;
case 2:
clrscr();
int d,e,sub;
cout<<"\tSUBTRACT TWO NUMBERS"<<endl;
cout<<"-------------------------------"<<endl;
cout<<"Enter 1st Number : ";
cin>>d;
cout<<"Enter 2nd Number : ";
cin>>e;
sub=d-e;
cout<<"Subtraction is : "<<sub<<endl;
break;
case 3:
clrscr();
int f,g,mul;
cout<<"\tMULTIPLY TWO NUMBERS"<<endl;
cout<<"--------------------------------"<<endl;
cout<<"Enter 1st Number : ";
cin>>f;
cout<<"Enter 2nd Number : ";
cin>>g;
mul=f*g;
cout<<"Multiplication is : "<<mul<<endl;
break;
case 4:
clrscr();
float h,i,div;
cout<<"\tDIVISION OF TWO NUMBERS"<<endl;
cout<<"--------------------------------"<<endl;
cout<<"Enter 1st Number : ";
cin>>h;
cout<<"Enter 2nd Number : ";
cin>>i;
div=h/i;
cout<<"Division is : "<<div<<endl;
break;
case 5:
clrscr();
float log_value,log_result;
cout<<"\tTake Logarithem Of Any Value"<<endl;
cout<<"--------------------------------------------"<<endl;
cout<<"Enter Any Number = ";
cin>>log_value;
log_result=log(log_value);
cout<<"The Logarithem Result is = "<<log_result<<endl;
break;
case 6:
clrscr();
float sin_value,sin_result;
cout<<"\tTake Sin Of Any Value"<<endl;
cout<<"--------------------------------------"<<endl;
cout<<"Enter Any Number = ";
cin>>sin_value;
sin_result=sin(sin_result);
cout<<"Sin Result is = "<<sin_result<<endl;
break;
case 7:
clrscr();
float cos_value,cos_result;
cout<<"\tTAKE COSINE OF ANY VALUE"<<endl;
cout<<"----------------------------------------"<<endl;
cout<<"Enter Any number = ";
cin>>cos_value;
cos_result=cos(cos_result);
cout<<"Cos Result is = "<<cos_result<<endl;
break;
case 8:
clrscr();
float tan_value,tan_result;
cout<<"\tTAKE TAN OF ANY VALUE"<<endl;
cout<<"---------------------------------------"<<endl;
cout<<"Enter Any Number = ";
cin>>tan_value;
tan_result=tan(tan_value);
cout<<"Tan Result is = "<<tan_result;
break;
case 9:
clrscr();
int num,power,pow_result;
cout<<"\tTAKE POWER OF ANY VALUE"<<endl;
cout<<"----------------------------------------"<<endl;
cout<<"Enter Any Number = ";
cin>>num;
cout<<"Enter Power of number = ";
cin>>power;
pow_result=pow(num,power);
cout<<"Result is = "<<pow_result;
break;
case 10:
clrscr();
float sqrt_value,sqrt_result;
cout<<"\tFIND SQUARE ROOT OF ANY VALUE"<<endl;
cout<<"-----------------------------------------------"<<endl;
cout<<"Enter Any Number = ";
cin>>sqrt_value;
sqrt_result=sqrt(sqrt_value);
cout<<"Square Root Result is = "<<sqrt_result<<endl;
break;
case 11:
clrscr();
float area1,h1,base;
cout<<"\tAREA OF TRIANGLE"<<endl;
cout<<"---------------------------------"<<endl;
cout<<"Enter The Height : ";
cin>>h1;
cout<<"Enter The Base : ";
cin>>base;
area1=h1*base/2;
cout<<"Area Of Triangle is : "<<area1;
break;
case 12:
clrscr();
cout<<"VOLUME OF TRIANGLE"<<endl;
cout<<"------------------------------"<<endl;
float side1,side2,side3,volume;
cout<<"Enter Length of Side 1 : ";
cin>>side1;
cout<<"Enter Length of Side 2 : ";
cin>>side2;
cout<<"Enter Length of side 3 : ";
cin>>side3;
volume=side1+side2+side3;
cout<<"Volume of Triangle is : "<<volume;
break;
case 13:
clrscr();
cout<<"\tAREA OF RECTANGLE"<<endl;
cout<<"-----------------------------------"<<endl;
float area2,len,wid;
cout<<"Enter The Length Of Rectangle : ";
cin>>len;
cout<<"Enter The Width Of Rectangle : ";
cin>>wid;
area2=len*wid;
cout<<"Area Of Rectangle is : "<<area2;
break;
case 14:
clrscr();
cout<<"\tVOLUME OF RECTANGLE"<<endl;
cout<<"-------------------------------"<<endl;
float vol,leng,width;
cout<<"Enter The Lenght : ";
cin>>leng;
cout<<"Enter The Width ; ";
cin>>width;
vol=2*(leng+width);
cout<<"Volume of Rectangle is : "<<vol;
break;
case 15:
clrscr();
float r,a2;
cout<<"\tFIND AREA OF CIRCLE"<<endl;
cout<<"-------------------------------------"<<endl;
cout<<"Enter radius : ";
cin>>r;
a2=3.14*r*r;
cout<<"Area is : "<<a2<<endl;
break;
case 16:
clrscr();
float r1,c1;
cout<<"\tFIND CIRCMFERENCE OF CIRCLE"<<endl;
cout<<"---------------------------------------------"<<endl;
cout<<"Enter Radius : ";
cin>>r1;
c1=2*3.14*r1;
cout<<"Circumference is : "<<c1<<endl;
break;
case 17:
clrscr();
int vf,vi1,ac,t;
cout<<"\tVf=Vi+at"<<endl;
cout<<"-----------------------------"<<endl;
cout<<"Enter Initial Velocity = ";
cin>>vi1;
cout<<"Enter Time = ";
cin>>t;
cout<<"Enter Accelration = ";
cin>>ac;
vf=vi1+ac*t;
cout<<"Final Velocity is = "<<vf<<endl;
break;
case 18:
clrscr();
float s18,a18,t18,vi18;
cout<<"\tS=Vi*t+a*t*t/2"<<endl;
cout<<"------------------------------------"<<endl;
cout<<"Enter initial Speed : ";
cin>>vi18;
cout<<"Enter time : ";
cin>>t18;
cout<<"Enter accelration : ";
cin>>a18;
s18=vi18*t18+a18*t18*t18/2;
cout<<"Distance Covered is : "<<s18<<endl;
break;
case 19:
clrscr();
int s1,v,t1;
cout<<"\tS=v*t"<<endl;
cout<<"---------------------------------"<<endl;
cout<<"Enter Velocity = ";
cin>>v;
cout<<"Enter Time = ";
cin>>t1;
s1=v*t1;
cout<<"Distance is = "<<s1<<endl;
break;
case 20:
clrscr();
float f1,m,ac1;
cout<<"\tFIND THE FORCE"<<endl;
cout<<"-----------------------------------"<<endl;
cout<<"Enter The Mass : ";
cin>>m;
cout<<"Enter Accelration : ";
cin>>ac1;
f1=m*ac1;
cout<<"Force is : "<<f1<<endl;
break;
case 21:
clrscr();
float de,ma,vo;
cout<<"\tFind The Denisty"<<endl;
cout<<"---------------------------------------"<<endl;
cout<<"Enter Mass : ";
cin>>ma;
cout<<"Enter Volume : ";
cin>>vo;
de=ma/vo;
cout<<"Denisty is : "<<de<<endl;
break;
case 22:
clrscr();
float cel,faren;
cout<<"\tCONVERT TEMPERATURE IN FARENHEIT FROM CELSIUS "<<endl;
cout<<"---------------------------------------------------------"<<endl;
cout<<"Enter Temperature in Celsius : ";
cin>>cel;
faren=cel*9/5+32;
cout<<"Temperature in Farenheit is : "<<faren<<endl;
break;
case 23:
clrscr();
float cel1,faren1;
cout<<"\tCONVERT TEMPERATURE IN CELSIUS FROM FARENHEIT"<<endl;
cout<<"-----------------------------------------------------"<<endl;
cout<<"Enter Temperature in Farenheit : ";
cin>>faren1;
cel1=(faren1-32)*5/9;
cout<<"Temperature in celsius is : "<<cel1;
break;
case 24:
exit(0);
break;
default:
cout<<"Invlid Number ";
}
cout<<endl;
cout<<"COPY RIGHT ARE RESERVED";
getch();
clrscr();
}
}