This is just pseudo code by the way. Just trying to learn the logic and design of programming.
classCalculatorProgram main() num numberA, numberB num operatorSym output “Welcome to the Calculator Program” output “(+)Addition” output “(-)Subtraction” output “(*)Multiplication” output “(/)Division” output “(Q)Quit output “Please enter a number“ input numberA output “Please enter an operator symbol for the desired arithmetic” input operatorSym output “Please enter another number” input numberB num numResult if operatorSym = + then numResult = numberA + numberB else if operatorSym = - then numResult = numberA – numberB else if operatorSym = * then numResult = numberA * numberB else if operatorSym = / and numberB = 0 then output “You cannot divide by 0, please enter another number ” input numberB else if operatorSym = / then numResult = numberA/numberB endif endif endif endif endif output “You entered, “ numberA “ “ operatorSym “ “ numberB “ = ”numResult”.” return endClass
Should I put an IF/WHILE statement at the very beginning of my IF's to check whether or not the user typed "Q" to quit?
Thanks,
wolfman


Sign In
Create Account


Back to top









