Question: 1-You are to write a program that acts like a calculator. The program will first ask the user to input two double-type numbers, to be

 1-You are to write a program that acts like a calculator.

1-You are to write a program that acts like a calculator. The program will first ask the user to input two double-type numbers, to be used in a calculation on. Then, your program will ask the user to input a single character-one of a, s, m or d, which mean that the two numbers should be added, subtracted, multiplied or divided, respectively Your program should also obey the following specifications: 1. The specific calculation should be: firstNumber operator secondNumber, where operator is one of+, - ,/, and where first Number is the first number the user inputs, and secondNumber is the second 2. If the user's second Number is zero, and the division operation is requested, then your program should output the following: "Error, trying to divide by zero" 3. If the user inputs a character other than one of the four given, then your program should output: "Error, unknown calculation command given" Below are several sample outputs from an execution of the program, which are separated by the lines Run 1 Run 2- etc. In the sample output examples that follow, the user input appears after the colon character (:) and is followed by the enter key. Run 1 Enter first number: 4.0 Enter second number: 5.0 Enter calculation command (one of a, s, m, or d): a Sum of 4.00 and 5.00 is 9.00 Run 2 Enter first number: 55.6 Enter second number: 75.8 Enter calculation command (one of a, s, m, or d):s Difference of 55.60 from 75.80 is-20.20 Enter first number: 3.4 Enter second number: 2.8 Enter calculation command (one of a, s, m, or d): m Product of 3.40 and 2.80 is 9.52 Run 4 Enter first number: 90.0 Enter second number: 41.0 Enter calculation command (one of a, s, m, or d): d Division of 90.00 by 41.00 is 2.20 Run 5 Enter first number: 37.9 Enter second number: 0.0 Enter calculation command (one of a, s, m, or d): d Error, trying to divide by zero Run 6 Enter first number: 3.2 Enter second number: 1.8 Enter calculation command (one of a, s, m, or d):p Error, unknown calculation command given

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!