Question
Please complete an IPO chart and solution algorithm for the following code: import java.util.Scanner; public class simpleCalculator { public static void main(String[] args) { Scanner
Please complete an IPO chart and solution algorithm for the following code:
import java.util.Scanner; public class simpleCalculator { public static void main(String[] args) { Scanner sc= new Scanner(System.in); //Displaying menu.. System.out.println(" Calculator Program "); System.out.println(" ----------------------------------------------------------------------"); System.out.println(" A: Add"); System.out.println(" B: Subtract"); System.out.println(" C: Multiply"); System.out.println(" D: Divide"); System.out.println(" -----------------------------------------------------------------------"); System.out.print(" Please make a selection: "); String selection = sc.next(); //Read choice from user.. if (selection.equals("A")) { System.out.print(" Please enter the first number: "); int value1 = sc.nextInt(); //Read value1 from user.. System.out.print(" Please enter the second number: "); int value2 = sc.nextInt(); //Read value2 from user.. System.out.println(" " + value1 + " + " + value2 + " = " + (value1 + value2)); //Adding } else if (selection.equals("B")) { System.out.print(" Please enter the first number: "); int value1 = sc.nextInt(); //Read value1 from user.. System.out.print(" Please enter the second number: "); int value2 = sc.nextInt(); //Read value2 from user.. System.out.println(" " + value1 + " - " + value2 + " = " + (value1 - value2)); //Subtract } else if (selection.equals("C")) { System.out.print(" Please enter the first number: "); int value1 = sc.nextInt(); //Read value1 from user.. System.out.print(" Please enter the second number: "); int value2 = sc.nextInt(); //Read value2 from user.. System.out.println(" " + value1 + " * " + value2 + " = " + (value1 * value2)); //Multiply } else if (selection.equals("D")) { System.out.print(" Please enter the first number: "); int value1 = sc.nextInt(); //Read value1 from user.. System.out.print(" Please enter the second number: "); int value2 = sc.nextInt(); //Read value2 from user.. System.out.println(" " + value1 + " / " + value2 + " = " + (value1 / value2)); //Dividing } else{ System.out.println(" Please enter a valid choice..!! "); } sc.close(); } }
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