Question: Design an algorithm for implementing a simple calculator. We first prompt the user for two numbers on which they want to perform a calculation,

Design an algorithm for implementing a simple calculator. We first prompt the

 user for two numbers on which they want to perform a calculation, and then the operation they want to perform. The user enters either the words ADD, SUBTRACT, MULTIPLY, DIVIDE, REMAINDER, or EXPONENT, or the symbol 

Design an algorithm for implementing a simple calculator. We first prompt the user for two numbers on which they want to perform a calculation, and then the operation they want to perform. The user enters either the words ADD, SUBTRACT, MULTIPLY, DIVIDE, REMAINDER, or EXPONENT, or the symbol for the operation (+,-, *, /, %, ^). Perform the calculations based on the inputs entered by the user and display the result. Save your work into your external document (Assignment2.docx). Part 2: Convert the above algorithm into a Java program (SimpleCalculator.java). You can use a switch statement to determine the selected operation and case constants for each possible operation. Here are some sample runs: Welcome to my Simple Calculator You can perform the following Operations. Please type: ADD or for addition Note: SUBTRACT or - for subtraction MULTIPLY or for multiplication Let's Start. Enter the first operand: 5.5 Enter the second operand: 6.33 Enter your selection: SUBTRACT The result of subtracting 6.33 from 5.5 is -0.83 DIVIDE or for division REMAINDER or % for remainder EXPONENT or for exponentiation Welcome to my Simple Calculator You can perform the following Operations. Please type: ADD or for addition SUBTRACT or - for subtraction MULTIPLY or* for multiplication DIVIDE or for division REMAINDER or % for remainder EXPONENT or for exponentiation Let's Start. Enter the first operand: 8 Enter the second operand: 0 Enter your selection: / Dividing by e is not allowed Before performing division, you must check whether the divisor is 0 (compare its value to 0.0). If it is 0.0, print an error message; otherwise, perform the division. Test your program with different inputs.

Step by Step Solution

3.43 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres an algorithm for implementing a simple calculator Prompt the user for two numbers on which they want to perform a calculation Prompt the user to ... View full answer

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 Programming Questions!