example of a menu driven program create a simple calculator that will add subtract multiply and divide values entered by the user */ import java. util.*; //used to include scanner public class menu...




example of a menu driven program create a simple calculator that will add subtract multiply and divide values entered by the user */ import java. util.*; //used to include scanner public class menu Example { public static void main(String arg s[]) { //declare a scanner for user Input Scanner user Input = new Scanner(System .in); int choice; int value1, value2

double.  number; //hold result of integer value do { //display our menu System .out .print ln("*** Calculator v1.0***"); System .out. print ln("1, Addition"); System. out. Print ln("2, Sub traction"); System .out. print ln("3, Multiplication"); System. out. print ln("4, Division");

System. out. Print ln("5, Modulous"); System. out. print ln("6. Exit"); System. Out .print ln("**********************"); System. out. print ln("Please enter your choice:"); //get user input choice = user Input .next I n t(); //switch the choice from user switch(choice)

{ case 1://addition System. Out .print ln("addition"); System. out. print ln("Please enter two values to be added"); value1 = user I n put. Next In t(); value2 = user Input. Next In t();

System .out. print ln (value1 + " + " + value2 + " = " + (value1+value2); break; case 2://subtraction System .out. print ln("subtraction"); System. out. print ln("Please enter two values to be subtracted"); value1 = user Input. Next In t(); value2 = user Input .next In t();

System .out .print ln(value1 + " - " + value2 + " = " + (value1-value2); break; case 3://multiplication System .out. print ln("multiplication"); System .out. print ln("Please enter two values to be multiplication"); value1= user Input .next In t(); value2 = user Input .next In t(); System .out. print ln(value1 + " * " + value2 + " = " + (value18value2); break;

case 4://division System .out .print ln("division"); System. out. print ln("Please enter two values to be divided"); value1= user Input .next In t(); value2 = user Input .next In t(); number = (double)value1 / value2; //type cast System .out. print ln(value1 + " / " + value2 + " = " + number); break; case 5://division System. out. print ln("multiplication"); System. out. print ln("Please enter two values to be divided"); value1= user Input. next In t(); value2 = user In put. Next In t();System. Out .print ln(value1 + " % " + value2 + " = " + (value1%value2); break; case 6://exit System. out. print ln ("You have chose exit!"); break; default://default System .out. print ln("You entered an invalid choice"); } }while(choice != 5); }//main }//class
May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here