Java Quiz (2): Show your java strength : ********Result**********

28 views
Skip to first unread message

Kamlesh Paunikar

unread,
Oct 6, 2009, 6:15:42 AM10/6/09
to Code Gurukul
Hello All
Complete code should not use if-else or loop it should use
only switch case statement.
Here is the code...



/**
*
* @author Kamlesh Paunikar
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int n = -34; //Test your any integer number here
switch (n) {
case 0:
System.out.println("Zero");
break;
default:
int check = n / Math.abs(n);
switch (check) {
case 1:
System.out.println("+ve");
break;
case -1:
System.out.println("-ve");
break;
}
}
}
}


Now ready for the next simmmmmmmmmmmmmple question............

Thanks
KP Solutions
Reply all
Reply to author
Forward
0 new messages