5.4k views
0 votes
Write pseudocode for a program which will ask a user to enter two numbers a and b. It then asks what operation is to be performed: a*b, a/b, a//b or a%b, performs the appropriate calculation and prints out the result. ​If the user does not enter a valid response, print an error message.

1 Answer

7 votes

get int input for a

get int input for b

get string input for operator

if a is not int or b is not int throw exception and print error

if operator is not * / // or % throw exception and print error

if operator is * do multiplication of a and b and make answer c

else if operator is / do division of a and b and make answer c

else if operator is // do floor division of a and b and make answer c

else if operator is % do floor modulo of a and b and make answer c

print c

User Horejsek
by
4.2k points