Due Fri 10/4 or Sat 10/5 (Depending on lab session day)
For this lab you will use Lab 4 code to create a java calculator by calling Methods.
Instructions:
Create a program that continuously prints a menu of options for the user to select from, the options are addition, subtraction, multiplication, division, modulus, factorial and an option for the user to exit the program.
Reuse the code for while loops and switch statements from lab 4
Create a method per each option:
Addition(int x, int y)
Subtraction(int x, int y)
Multiplication(int x, int y)
Division(int x, int y) - > (x divided by y)
Modulus(int x, int y)
Factorial(int x)
3. Ask the user to select an option if they wish to complete a mathematical operation prompt the user for the two numbers and call the correct method to perform this operation.
4. Inside the method you will perform the operation using the method parameters.
5. The method should return the result as int.
6. If the user selects to exit the program exit the loop and terminate the program.
Pointers:
How to respond if a user enters an option that is not on the list?
If user chooses to divide by zero how can you handle that? hint -> Java exceptions using try and catch
If a user enters factorial option, you only need to take in one number not two how can you use if statements to handle that change?
Starter Code: