fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String code = "20098";
  13.  
  14. char zipCode;
  15. zipCode=code.charAt(0);
  16.  
  17. switch (zipCode) {
  18. case '0': case '2': case '3':
  19. System.out.println(zipCode + " is on the East Coast.");
  20. break;
  21. case '4': case '5': case '6':
  22. System.out.println(zipCode + " is in the Central Plains Area.");
  23. break;
  24. case '7':
  25. System.out.println(zipCode + " is in the South.");
  26. break;
  27. case '8': case '9':
  28. System.out.println(zipCode + " is in the West.");
  29. break;
  30. default:
  31. System.out.println(zipCode + " is an invalid ZIP Code.");
  32. }
  33. }
  34. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
2 is on the East Coast.