Question: 1. (10 points) Write a C++ program named hw3_1.cpp that emulates a simple calculator. First, your program prompts a user to enter a math operation
1. (10 points) Write a C++ program named hw3_1.cpp that emulates a simple calculator. First, your program prompts a user to enter a math operation to be performed. Then, it asks for two numbers to perform the operation on. If the user types in an operator that we haven't specified, you should print out an error message, as seen below. The following shows a sample execution of your program. When the instructor runs your program for grading, your program should display the result as below. Note that the boldfaced numbers are entered by a user. Welcome to the Hartnell Calculator Enter operation to be performed (Note you must type in a+,,, or 1 ): * Enter the first number: 20 Enter the second number: 15 2015=300 Here is another sample run, this one with an incorrect operator Welcome to the Hartnell Calculator Enter operation to be performed (Note you must type in a +,,, or /1 : \# Sorry, this isn't a valid operator. Another sample run Welcome to the Hartnell Calculator Enter operation to be performed (Note you must type in a +,,+, or /1 : / Enter the first number: 3.5 Enter the second number: 2.0 3.5/2=1.75
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
