Question: Use nested if or switch-case, Scanner, ArrayList USING JAVA 1. Add a new package named hw2p3 to the project. a. Right click the package and
Use nested if or switch-case, Scanner, ArrayList USING JAVA
1. Add a new package named hw2p3 to the project.
a. Right click the package and add a new class named Calculator without a main method.
b. Add another class named Launcher with a main method. You will see Launcher.java in the Package Explorer. c. Write code for a method of the Calculator class. i. Prompt "Enter first operand of double:" ii. Prompt "Enter second operand of double:" iii. Prompt "Enter an operator (*, /, -, +, or %):" iv. Print result (e.g., for the 3, 5, and +, it would print "3 + 5 is 8") and store the "3 + 5 is " in an ArrayList and 8 in an ArrayList. v. Then, prompt "Continue? (y for yes, n for no)" (Note: Repeat the steps i thru iv above as long as user types y. Otherwise, halt the operations). vi. Once the operation is stopped, print all the results from the array lists similar to the following:
3 + 5 = 8.0
3 * 5 = 15.0
3 p 5 = 243
etc.
2. Write code for the main() method of the Launcher class to run the program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
