Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions