Alright, so I just started learning c++ a few hours ago with no prior programming experience, and i'm working on a somewhat simple (probably more complicated than it needs to be) calculator script.
Here's the code I have so far (assuming i get the code tags right lol):
Now, my problem is that my compiler doesn't show that there are any problems, yet when i run the program, it quits after I get to the part where it says "Would you like to add, subtract, multiply, or divide?" like it can't recognize what I am saying. Any suggestions here guys? I've been doing my research and i'm still stumped ;|Code:#include <iostream> using namespace std; int main() { int a, b, c, d, e, f; int resultadd, resultsub, resultmul, resultdiv; int add, subtract, multiply, divide; resultadd = a + c; resultsub = a - d; resultmul = a * e; resultdiv = a / f; cout<<"Welcome to my first calculator script. Please enter a number: "; cin>>a; cin.ignore(); cout<<"You entered the number "<<a<<".\n"; cout<<"Would you like to add, subtract, multiply, or divide? \n"; cin>>b; cin.ignore(); if (b==add) { cout<<"What number would you like to add to "<<a<<"?\n"; cin>>c; cin.ignore(); cout<<"Your answer is "<<resultadd<<".\n"; } else if (b==subtract) { cout<<"What number would you like to subtract from "<<a<<"?\n"; cin>>d; cin.ignore(); cout<<"Your answer is "<<resultsub<<".\n"; } else if (b==multiply) { cout<<"What number would you like to multiply "<<a<<" with?\n"; cin>>e; cin.ignore(); cout<<"Your answer is "<<resultmul<<".\n"; } else if (b==divide) { cout<<"What number would you like to divide "<<a<<" by?\n"; cin>>f; cin.ignore(); cout<<"Your answer is "<<resultdiv<<".\n"; } else { cout<<"I'm sorry, what? Please try again.\n"; cin>>b; cin.ignore(); } cout<<"Thank you for using my calculator script!"; cin.get(); }


LinkBack URL
About LinkBacks
Reply With Quote
