Hello Friends
The C++ code for both standard and scientific calculators will be discussed below this blog. In order to know how to make the code work kindly watch the video from my channel.If you haven't subscribed to my channel kindly SUBSCRIBE and hit the BELL icon in order to get notified about my future videos.
https://www.youtube.com/channel/UC9QngUvOPO-NfuOLZbY3pdg/featured
C++ Code for Standard and Scientific Calculator:
#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
int main()
{
system("color 4f");
long double a,b;
char e,c,d;
lab:
cout<<"If you want to use Standard Calculator press 'a'";
cout<<"\nIf you want to use Scientific Calculator press 'b'";
cout<<"\nPress 'a'(or)'b'=";
cin>>e;
system("cls");
system("color 30");
switch(e)
{
case 'a':
cout<<"\n*********************** WELCOME TO STANDARD CALCULATOR ************************";
cout<<"\n"<<" "<<"BY:";
cout<<"\n"<<" N.ANTO JUDE GEOFFREY"<<endl;
cout<<"\nRound(up)=< Round(down)=d";
cout<<"\nAdd=+ Substract=-";
cout<<"\nMultiply=* Divide=/";
cout<<"\nPercentage=% Less/Greater than=>"<<endl;
cout<<"\nEnter the operation(+,-,*,/,%,>,<,d)=";
cin>>c;
label:
switch(c)
{
case '+':
cout<<"\nEnter the first number for adding=";
cin>>a;
cout<<"\nEnter the second number for adding=";
cin>>b;
cout<<"\nAddition=";
cout<<a+b;
break;
case '-':
cout<<"\nEnter the first number for substracting=";
cin>>a;
cout<<"\nEnter the second number for substracting=";
cin>>b;
cout<<"\nsubstraction=";
cout<<a-b;
break;
case '*':
cout<<"\nEnter the first number for multiplying=";
cin>>a;
cout<<"\nEnter the second number for multiplying=";
cin>>b;
cout<<"\nMultiplication=";
cout<<a*b;
break;
case '/':
cout<<"\nEnter the first number for dividing=";
cin>>a;
cout<<"\nEnter the second number for dividing=";
cin>>b;
cout<<"\nDivision=";
cout<<a/b;
break;
case '%':
cout<<"\nEnter the number for which you need to find percentage=";
cin>>a;
cout<<"\nEnter the number out of which you need to find the percentage=";
cin>>b;
cout<<"\nPercentage value =";
cout<<(a*100)/b<<" %";
break;
case '>':
cout<<"\nEnter the first number for comparison=";
cin>>a;
cout<<"\nEnter the second number for comparison=";
cin>>b;
cout<<"\nThe operation is ";
if (a<b)
cout<<a<<"<"<<b;
else
cout<<a<<">"<<b;
break;
case '<':
cout<<"\nEnter the first number to round off(up)=";
cin>>a;
cout<<"\nEnter the second number to round off(up)=";
cin>>b;
cout<<"\nRound off(up) number of value 1=";
cout<<ceil(a);
cout<<"\nRound off(up) number of value 2=";
cout<<ceil(b);
break;
case 'd':
cout<<"\nEnter the first number to round off(down)=";
cin>>a;
cout<<"\nEnter the second number to round off(down)=";
cin>>b;
cout<<"\nRound off(down) number of value 1=";
cout<<floor(a);
cout<<"\nRound off(down) number of value 2=";
cout<<floor(b);
break;
default:
cout<<"ERROR OCCURRED";
break;
}
cout<<endl;
system("pause");
system("cls");
system("color 64");
cout<<"\nPress 's' key to continue and 'n' key to select the calculator and 'e' key to exit=";
cin>>d;
system("cls");
system("color f0");
switch(d)
{
case 's':
cout<<"\nNice Job!!!"<<"\nPlease continue";
cout<<"\nRound(up)=< Round(down)=d"<<"\nAdd=+ Substract=-";
cout<<"\nMultiply=* Divide=/"<<"\nPercentage=% Less/Greater than=>"<<endl;
cout<<"\nEnter the operation(+,-,*,/,%,>,<,d)=";cout<<"\nMultiply=* Divide=/"<<"\nPercentage=% Less/Greater than=>"<<endl;
cin>>c;
goto label;
break;
case 'n':
cout<<"\nGood Job!!!";
cout<<"\nKeep Working..."<<endl;
goto lab;
break;
case'e':
cout<<"\nThank you!!!!!!!!!!!!!!";
break;
default:
cout<<"ERROR OCCURRED";
break;
}
break;
case 'b':
cout<<"*********************** WELCOME TO SCIENTIFIC CALCULATOR ***********************";
cout<<"\n BY:";
cout<<"\n N.ANTO JUDE GEOFFREY";
cout<<"\nSin=+ Sec=% Sqrt=r";
cout<<"\nCos=- Cot=> Power=d";
cout<<"\nTan=* Log=< Modulus=m";
cout<<"\nCosec=/";
cout<<"\nEnter the operation(+,-,*,/,%,>,<,m,r,d)=";
cin>>c;
labe:
switch(c)
{
case '+':
cout<<"\nEnter the Sine value=";
cin>>a;
cout<<"\nSine value for first value=";
cout<<sin(a);
break;
case '-':
cout<<"\nEnter the cos value =";
cin>>a;
cout<<"\nCosine of value =";
cout<<cos(a);
break;
case '*':
cout<<"\nEnter the tan value =";
cin>>a;
cout<<"\nTangent of value =";
cout<<tan(a);
break;
case '/':
cout<<"\nEnter the cosec value =";
cin>>a;
cout<<"\nCosecant of value =";
cout<<1/sin(a);
break;
case '%':
cout<<"\nEnter the sec value =";
cin>>a;
cout<<"\nSecant of value =";
cout<<1/cos(a);
break;
case '>':
cout<<"\nEnter the cot value =";
cin>>a;
cout<<"\nCotangent of value =";
cout<<1/tan(a);
break;
case '<':
cout<<"\nEnter the log value =";
cin>>a;
cout<<"\nLogarithm of value =";
cout<<log(a);
break;
case 'm':
cout<<"\nEnter the mod value =";
cin>>a;
cout<<"\nModulus of value =";
cout<<fabs(a);
break;
case 'r':
cout<<"\nEnter the sqrt value =";
cin>>a;
cout<<"\nSquare root of value =";
cout<<sqrt(a);
break;
case 'd':
cout<<"\nEnter the base value=";
cin>>a;
cout<<"\nEnter the power value=";
cin>>b;
cout<<"\nPower the numbers=";
cout<<pow(a,b);
break;
default:
cout<<"ERROR OCCURRED";
break;
}
cout<<endl;
system("pause");
system("cls");
system("color a1");
cout<<"\nPress 's' key to continue and 'n' key to select the calculator and 'e' key to exit=";
cin>>d;
system("cls");
system("color 8c");
switch(d)
{
case 's':
cout<<"\nNice Job!!!";
cout<<"\nPlease continue";
cout<<"\nSin=+ Sec=% Sqrt=r";
cout<<"\nCos=- Cot=> Power=d";
cout<<"\nTan=* Log=< Modulus=m";
cout<<"\nCosec=/";
cout<<"\nEnter the operation(+,-,*,/,%,>,<,m,r,d)=";
cin>>c;
goto labe;
break;
case 'n':
cout<<"\nGood Job!!!";
cout<<"\nKeep Working..."<<endl;
goto lab;
break;
case'e':
cout<<"\nThank you!!!!!!!!!!!!!!";
break;
default:
cout<<"ERROR OCCURRED";
break;
}
break;
default:
cout<<"ERROR OCCURRED";
break;
}
cout<<endl;
system("pause");
return 0;
}
COPY THE CODE AND PASTE AND ENJOY!!!
No comments:
Post a Comment