Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a new Java class called: Calculator Write a program that will serve as a simple calculator The program should read a simple expression consisting
Create a new Java class called: Calculator Write a program that will serve as a simple calculator The program should read a simple expression consisting of two integer operands and one operator The program should then apply the operator to the operands to compute the result and print this on the screen To begin, you will get the input from the user. The user is expected to enter a single line of input two numbers with one or more characters (operator) between them. Acceptable operators eshould be one of the following Once you have the input, your program should determine what operator the user entered, and then apply the appropriate math calculation to the two numbers to calculate an answer: ser Enters: Do This: dd the two numbers Subtract the two numbers Multiply the two numbers Divide the two numbers, treating them as floating point numbers, and therefore roducing a floating point answe Divide the two numbers, treating them as integers, and therefore producing an integer answer (the quotient from performing a long division Divide the two numbers using long division, but produce the remainder Raise the first number to the power of the second number For your output, the program should repeat the equation back to the user, with an equals sign, followed by the answer-such as: 3 4 5 + 1 2 3 4 5 6 If the user enters an operator that is not in the set, output an error message saying "no such operator" If the user attempts to perform one of the three division operations, but the second number entered is zero, output an error message saying "division by zero" rogram runs. The The following is an example of what your MIGHT see on the screen when your p exact output depends on what values that the user types in while the program runs. Please be sure that you test ALL of the examples shown below with your program. The user's inputted values are shown below in italics Equation: 345 + 123 345123 456 Here is another example program run Equation: 78 /4 78 / 4=19.50
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started