#include <iostream> #include <cmath> #include <string> using namespace std; int main(){ cout<<"Welcome to my newly improved calculator program"<<endl; cout<<"Please enter some number"<<endl; double x; int sum =0; int total=0; int sub=0; double prod=1; double div=1; do { cin >>x; sum=sum+x; }while(x!=0); cout<<"Your total sum is "<<sum<<endl; cout<<"Please enter some numbers"<<sub<<endl; cout<<"Would you like to perform another math function today? "<<endl; char la; cin>>la; if(la=='q')cout<<"Thanks for using the program! "; else cout<<"Continue with the program! "; do{ cin>>x; sub=sub-x; }while(x!=0); cout<<"Your total difference is "<<sub<<endl; cout<<"Would you like to perform another math function today? "<<endl; char ba; cin>>ba; if(ba=='q')cout<<"Thanks for using the program! "; cout<<"Please enter some number"<<endl; do{ cin>> x; prod=prod*x; }while(x!=1); cout<<"Your total product is "<<prod<<endl; cout<<"Would you like to perform another math function today? "<<endl; char ca; cin>>ca; if(ba=='q')cout<<"Thanks for using the program! "; cout<<"Please enter some numbers"<<endl; do{ cin>>x; div=x/div; cout<<"Would you like to perform another math function today? "<<endl; char da; cin>>da; if(da=='q')cout<<"Thanks for using the program! "; }while(x!=1); cout<<"The ratio of your numbers are "<<div<<endl; cout<<"Would you like to perform another mathematical operation today? y/n"<<endl; char ch; cin >>ch; if(ch=='y' || ch=='Y'|| ch=='yes') cout<<"continue with the program"; else if(ch=='n' || ch=='N' || ch=='no' || ch=='NO') cout<<"you are done with the improved calculator program"<<endl; return 0; } |
Please enter some number: 8+8 + 8+....0. The Your total sum is [b]24 . Would you like to perform another math function today y/n? If you chose 'yes' ,continue with the sequence of math operations. If user chooses 'no' the program stops. |
Welcome to my newly improved calculator program! Please enter some number? : 8+8+8+0/ Your total sum is [b] 24 Would you like to continue with this program? y. |
Remove the statement where you output the phrase "Welcome to my newly improved calculator program!" and you will be closer to the result you want!:) |
#include <iostream> #include <cmath> #include <string> using namespace std; int main(){ cout<<"Please enter some number"<<endl; double x; int sum =0; int total=0; int sub=0; double prod=1; double div=1; do { cin >>x; sum=sum+x; }while(x!=0); cout<<"Your total sum is "<<sum<<endl; cout<<"Please enter some numbers"<<sub<<endl; cout<<"Would you like to perform another math function today? "<<endl; char la; cin>>la; if(la=='q')cout<<"Thanks for using the program! "; else cout<<"Continue with the program! "; do{ cin>>x; sub=sub-x; }while(x!=0); cout<<"Your total difference is "<<sub<<endl; cout<<"Would you like to perform another math function today? "<<endl; char ba; cin>>ba; if(ba=='q')cout<<"Thanks for using the program! "; cout<<"Please enter some number"<<endl; do{ cin>> x; prod=prod*x; }while(x!=1); cout<<"Your total product is "<<prod<<endl; cout<<"Would you like to perform another math function today? "<<endl; char ca; cin>>ca; if(ba=='q')cout<<"Thanks for using the program! "; cout<<"Please enter some numbers"<<endl; do{ cin>>x; div=x/div; cout<<"Would you like to perform another math function today? "<<endl; char da; cin>>da; if(da=='q')cout<<"Thanks for using the program! "; }while(x!=1); cout<<"The ratio of your numbers are "<<div<<endl; cout<<"Would you like to perform another mathematical operation today? y/n"<<endl; char ch; cin >>ch; if(ch=='y' || ch=='Y'|| ch=='yes') cout<<"continue with the program"; else if(ch=='n' || ch=='N' || ch=='no' || ch=='NO') cout<<"you are done with the improved calculator program"<<endl; return 0; } |