Starting from:
$30

$24

Bonus Assignment #1 Solution




Modify your Assignment3 so that we can check input errors. Please refer to the following Java code.







import java.util.Scanner;




public class inputError5 {




public static void main(String[] args) {




Scanner consol=new Scanner(System.in);




int choice=0;




while(true){




System.out.println("============================="); System.out.println("= 1. function1 ="); System.out.println("= 2. function2 ="); System.out.println("= 3. function3 ="); System.out.println("============================="); System.out.print("Select : ");




choice= consol.nextInt();




switch(choice){




case 0: System.out.println("Bye!! ");




System.exit(0);




case 1: function1();




break;




case 2: function2();




break;




case 3: function3();




break;




default:System.out.println("Wrong number!! Type 1~3 "); break;




}




} // while




}







public static void function1(){




System.out.println("function1");




}




public static void function2(){




System.out.println("function2");




}




public static void function3(){




System.out.println("function3");




}

}

More products