Would you like to make this site your homepage? It's fast and easy...
Yes, Please make this my home page!
/*
Author: ZT
Date: Jun 23,2017
Purpose: to use the SWITCH statement with different input
Arguments given in the commadn line computer response (1-5)
EXAMPLE:
java Appl_3 1
the output is
Hello Java 2 SE ....1
where is the _welcome1() method is called
if no arguments supplied the output is
No option selected
*/
public class Appl_3{
public static void main(String args[]){
int i,select=0;
/*
for(i=0;i 0 )
select=Integer.parseInt(args[0]); // convert String into integer
switch(select){
case 1: _welcome1(); ;break;
case 2: _welcome2(); ;break;
case 3: _welcome3(); ;break;
case 4: _welcome4(); ;break;
case 5: _welcome5(); ;break;
case 6: _welcome6(); ;break;
case 0: System.out.println("No option selected");break;
}
//
} // end of main() method
static void _welcome1(){
System.out.println("Hello Java 2 SE ....1");
}
static void _welcome2(){
System.out.println("Hello Java 2 SE.....2 ");
}
static void _welcome3(){
System.out.println("Hello Java 2 SE ...... 3");
}
static void _welcome4(){
System.out.println("Hello Java 2 SE ....4");
}
static void _welcome5(){
System.out.println("Hello Java 2 SE.....5 ");
}
static void _welcome6(){
System.out.println("Hello Java 2 SE ...... 6");
}
} // End of class Appl_3