This has been a nightmare. I'm coding this in C++. I'm supposed to enter a letter, and it's supposed to do the following depending on the letter. a is for addition, s is for subtraction, m is for multiplication, and d is for division. Any other letters is supposed to display an error message. Anyway, when I enter a, not only get the addition of the two numbers, I also get the quotient. When I enter s, I get the subtraction AND the quotient. When I enter m, I get the multiplication AND the difference. And when I enter d, I get the quotient AND the difference. What is going on? Also, when I enter a number other than a, s, m, or d, not only do I get, "Invalid letter" (Which I want), I also get this. Here is what I get. Please help me. I've included the code. Thank you!
/*
Enter letter:G
Invalid letter
Difference:4011944
Quotient:501494
Press any key to continue . . .
*/
_______________________________
//declare variables
int sum;
int difference;
int product;
int quotient;
2007-03-07
14:21:22
·
4 answers
·
asked by
Christi
4