Question: For this lab, we will be creating a four function calculator. The calculator will handle simple mathematical expressions of one of the four following forms:

 For this lab, we will be creating a four function calculator.The calculator will handle simple mathematical expressions of one of the four

For this lab, we will be creating a four function calculator. The calculator will handle simple mathematical expressions of one of the four following forms: - n+m - nm - nm - nm 1. The program will accept user input that is one line long and is in one of the accepted formats. The code will then print out the appropriate mathematical answer or an error message. 2. The program will continue looping in a sentinel-controlled loop until the user enters ' q ', at which point the program will break out of the loop. 3. The user is prompted to enter an expression by the prompt ">> " 4. The user will enter one line of input of the correct form. Note, there is no need for validation here. Assume that the form is correct. 5. Using the methods of the Scanner class, determine whether to exit or calculate a value. 6. Each operation will be handled in one of sixteen overloaded static method. The method signatures, using UML conventions are: - add(n : integer, m : integer ): integer - add (n: double, m : double ): double - add(n : integer, m : double): double - add (n: double, m : integer) : double - subtract(n : integer, m : integer ): integer - subtract (n : double, m : double ): double - subtract (n : integer, m : double ) : double - subtract( n : double, m : integer ): double - multiply( n : integer, m : integer ): integer - multiply( n : double, m : double ): double - multiply( n : integer, m : double ): double - multiply( n : double, m : integer ) : double - divide( n : integer, m : integer ): integer - divide( n : double, m : double ): double - divide( n : integer, m : double ): double - divide( n : double, m : integer ): double 7. Notes: 1. If you read the first token on the input, and it is the single-character string "q", there is no need (or ability!) to check the rest of the line. stop now, before trying to read the rest of the non-existent line. 2. If the first token is NOT "' q "' then read the next two tokens as strings and convert to the appropriate data type 3. Use the valueOf methods of classes Integer and Double to transform a String value to a numeric one, when needed. 1. The determination of using Integer or Double is strictly determined by the presence of the ". "the decimal point). If there is no decimal point in the string, use Integer. If there is a decimal point in the sting, use Double. 4. This looks like a lot, but there's a lot of repetition, and a copy and modify strategy will help. Also, each of the sixteen methods should be one-liners 5. There must be a space on either side of the operator like the line below, or you will ruin your week. It is hard to parse the line, otherwise. 6. Integer division truncates and returns an integer 7. Dividing by zero produces an output of "Error

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!