Question: Create a C++ program code which accepts 5 commands from the user: Command A is used to display the absolute value of an integer entered
Create a C++ program code which accepts 5 commands from the user:
Command A is used to display the absolute value of an integer entered by the user;
Command X is used to display the maximum of 2 integers entered by the user;
Command N is used to display the minimum of 2 integers entered by the user;
Command S is used to display the square of an integer entered by the user;
Command Q is used to quit the program.
Other requirements: The program must run until the user enters the Q command; Commands can be entered in upper or lower case; The program must neatly display the available commands to the user and prompt for a command at the beginning of each operation; The program must display an error message to the user if he/she enters an unrecognized command; Use printf statements to display output text indicating which command was executed, as well as the answer, e.g. printf("\The minimum value of %d and %d is %d. ", input1, input2, output); The program may not prompt the user to enter number values until AFTER the command is entered; Use a switch-case statement to process the 5 commands; Use if-else to calculate absolute value; Use the conditional operator to calculate the minimum & maximum values;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
