Question: Task list: 1. Create a source code file named lab16.cpp. 2. From the main function, start by prompting the user for a choice as: What
Task list:
1. Create a source code file named lab16.cpp. 2. From the main function, start by prompting the user for a choice as: What action do you want to perform? (a=add, s=subtract, m=multiply, d=divide, x=mod) and save the response in a variable of type char (will contain either a, s, m, d, or x). 3. Prompt the user for 2 additional numeric values of type int. 4. Create and call a function and pas the 3 argument variables that the user just entered. Notice that the sample function above has only 2 argument variables. 5. The function should use the switch statement to calculate the result. 6. Refer to the expected output listing below.
SAMPLE OUTPUT
/user/faculty
What action do you want to perform?
(a=add, s=subtract, m=multiply, d=divide, x=mod)
a
Enter first number
9
Enter second number
4
The result is 13
/user/faculty
What action do you want to perform?
(a=add, s=subtract, m=multiply, d=divide, x=mod)
s
Enter first number
9
Enter second number
4
The result is 5
/user/faculty
What action do you want to perform?
(a=add, s=subtract, m=multiply, d=divide, x=mod)
m
Enter first number
9
Enter second number
4
The result is 36
/user/faculty
What action do you want to perform?
(a=add, s=subtract, m=multiply, d=divide, x=mod)
d
Enter first number
9
Enter second number
4
The result is 2
/user/faculty
What action do you want to perform?
(a=add, s=subtract, m=multiply, d=divide, x=mod)
x
Enter first number
9
Enter second number
4
The result is 1
/user/faculty
What action do you want to perform?
(a=add, s=subtract, m=multiply, d=divide, x=mod)
g
Enter first number
9
Enter second number
4
Wrong choice.
I am returning zero. The result is 0
/user/faculty
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
