Menu - public class Menu { public static void main (String...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public class Menu { public static void main (String args) { char menuchoice; do { System.out.print("\n--------------------------\n\nMenu:\n1.Addition\n2.Subtraction\ n3.Multiplication\n4.Division\n5.Quit\n\n--------------------------\n\n"); menuchoice = IO.readChar(); if (menuchoice>='a' && menuchoice<='e') { System.out.print("Enter first number: "); double num1 = IO.readDouble(); System.out.print("Enter second number: "); d double num2 = IO.readDouble(); if (menuchoice == 'a') { IO.outputDoubleAnswer(num1 + num2); } else if (menuchoice == 'b') { IO.outputDoubleAnswer(num1 - num2); } else if (menuchoice == 'c') { IO.outputDoubleAnswer(num1 * num2); } else { while(num2==0) { System.out.print("Cannot divide by 0. Enter number 2 again: "); num2 = IO.readDouble(); } IO.outputDoubleAnswer(num1 / num2); } } else if (menuchoice != 'e') { IO.reportBadInput(); } } } } while(menuchoice!= 'e'); ...
View Full Document

Ask a homework question - tutors are online