//Selctable calculator
/* with fixes labeled below
XVIII
*/
#include<iostream>
usingnamespace std;
int main()
{
cout<<"\nCalculator 2.0";
cout<<"\nThe calculator where you can select the op.";
cout<<"\nEnter one integer:";
int Num1=0;
int Num2=0;
int Result=0;
char Result2;
cin>>Num1;
USERSELECTION:
cout<<"\nEnter the operation.";
cout<<"Enter 'm' to multiply, 'd'to divide, 'a' to add,\n";
cout<<"'s' to subtract, 'c' to square, & 'q' to cube\n";
char Userselection= '\0';
cin>>Userselection;
{
if (Userselection=='c')
{
Result=Num1*Num1;
goto RESULTDISPLAY;
}
elseif(Userselection=='q')
{
Result=Num1*Num1*Num1;
goto RESULTDISPLAY;
}
elseif (Userselection=='27';) //continue
{
Result2="Great job, you achived COWNUM";
}
elseif(Userselection=='m')
Result=Num1*Num2;
elseif (Userselection=='d')
Result=Num1/Num2;
elseif (Userselection=='a')
Result=Num1+Num2;
elseif (Userselection=='s')
Result=Num1-Num2;
else
cout<<"\nYou entered an invalid answer. Try again.";
goto USERSELECTION;
cout<<"\nEnter another integer:";
cin>>Num2;
cout<<"\nNum1 is "<<Num1<<".";
cout<<"\nNum2 is"<<Num2<<".";
cout<<"\nDo you wish to change these numbers?";
RESULTDISPLAY://Result Display
cout<<"\nWELCOME TO RESULT DISPLAY";
cout<<"\n\t Your Result is";
cout<<Result"\n";
cout<<"Result2 is "<<Result2"\n";
cout<<"Goodbye!!!!!";
return 0;
}
//Selctable calculator
/* with fixes labeled below
XVIII
*/
#include<iostream>
#include<string>
usingnamespace std;
int main()
{
cout<<"\nCalculator 2.0";
cout<<"\nThe calculator where you can select the op.";
cout<<"\nEnter one integer:";
int Num1=0;
int Num2=0;
int Result=0;
string Result2;
cin>>Num1;
USERSELECTION:
cout<<"\nEnter the operation.";
cout<<"Enter 'm' to multiply, 'd'to divide, 'a' to add,\n";
cout<<"'s' to subtract, 'c' to square, & 'q' to cube\n";
char Userselection= '\0';
cin>>Userselection;
{
if (Userselection=='c')
{
Result=Num1*Num1;
goto RESULTDISPLAY;
}
elseif(Userselection=='q')
{
Result=Num1*Num1*Num1;
goto RESULTDISPLAY;
}
elseif (Userselection=='27') //continue
{
Result2="Great job, you achived COWNUM";
}
elseif(Userselection=='m')
Result=Num1*Num2;
elseif (Userselection=='d')
Result=Num1/Num2;
elseif (Userselection=='a')
Result=Num1+Num2;
elseif (Userselection=='s')
Result=Num1-Num2;
else
{
cout<<"\nYou entered an invalid answer. Try again.";
goto USERSELECTION;
}
cout<<"\nEnter another integer:";
cin>>Num2;
cout<<"\nNum1 is "<<Num1<<".";
cout<<"\nNum2 is"<<Num2<<".";
cout<<"\nDo you wish to change these numbers?";
RESULTDISPLAY://Result Display
cout<<"\nWELCOME TO RESULT DISPLAY";
cout<<"\n\t Your Result is";
cout<<Result<<"\n";
cout<<"Result2 is "<<Result2<<"\n";
cout<<"Goodbye!!!!!";
return 0;
}
I can't figure out what to do to get decimals in division...
for decimals instead of integers, use doubles. they can use decimals. You could also add a place for remainders in division.
I have My own version here:
//Selctable calculator
/* with fixes labeled below
XVIII
*/
#include<iostream>
#include<string>
usingnamespace std;
int main()
{
cout<<"\nCalculator 2.0";
cout<<"\nThe calculator where you can select the op.";
cout<<"\nEnter one integer:";
int Num1=0;
int Num2=0;
int Result=0;
string Result2;
cin>>Num1;
USERSELECTION:
cout<<"\nEnter the operation.";
cout<<"Enter 'm' to multiply, 'd'to divide, 'a' to add,\n";
cout<<"'s' to subtract, 'c' to square, & 'q' to cube\n";
char Userselection= '\0';
cin>>Userselection;
{
if (Userselection=='c')
{
Result=Num1*Num1;
goto RESULTDISPLAY;
}
elseif(Userselection=='q')
{
Result=Num1*Num1*Num1;
goto RESULTDISPLAY;
}
elseif(Userselection=='m')
Result=Num1*Num2;
elseif (Userselection=='d')
{
Result=Num1 / Num2;
cout<<"\n\t Your Result is";
cout<<Result<<"\n";
cout<<"Result2 is "<<Result2<<"\n";
cout<<"Goodbye!!!!!";
}
elseif (Userselection=='a')
Result=Num1+Num2;
elseif (Userselection=='s')
Result=Num1-Num2;
else
{
cout<<"\nYou entered an invalid answer. Try again.";
goto USERSELECTION;
}
}
cout<<"\nEnter another integer:";
cin>>Num2;
cout<<"\nNum1 is "<<Num1<<".";
cout<<"\nNum2 is"<<Num2<<".";
cout<<"\nDo you wish to change these numbers?";
RESULTDISPLAY://Result Display
cout<<"\nWELCOME TO RESULT DISPLAY";
return 0;
}