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. static Scanner input = new Scanner(System.in);
  11.  
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. getUserInput();
  15. }
  16.  
  17. static void getUserInput() {
  18. System.out.println("enter odds or evens");
  19. String pref = input.nextLine();
  20. checkOption(pref);
  21. }
  22.  
  23. static void result(String s) {
  24. System.out.println("You chose " + s);
  25. }
  26.  
  27. static void checkOption(String option) {
  28. if (option.equalsIgnoreCase("odds") || option.equalsIgnoreCase("evens")) {
  29. result(option);
  30. } else {
  31. getUserInput();
  32. }
  33. }
  34. }
Success #stdin #stdout 0.07s 4575232KB
stdin
wrong entry
another one
odds
stdout
enter odds or evens
enter odds or evens
enter odds or evens
You chose odds