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 showMenu()
  11. {
  12. System.out.print('\u000c');
  13. System.out.println("1 - Compute Change \n");
  14. System.out.println("2 - Estimate Feast \n");
  15. System.out.println("3 - \n");
  16. System.out.println("4 - \n");
  17. System.out.println("5 - I'm broke, get me out of here\n");
  18. System.out.println("Select Option:\n");
  19. }
  20.  
  21. public static void StackPost()
  22. {
  23. System.out.println("Welcome to the Bank of Winterfell");
  24. try(Scanner in = new Scanner(System.in))
  25. {
  26. int selection;
  27. do
  28. {
  29. showMenu();
  30. selection = in.nextInt();
  31.  
  32. switch (selection)
  33. {
  34. case 1:
  35. // get input, compute then decision:
  36. while(true)
  37. {
  38. int something = in.nextInt();
  39. int somethingElse = in.nextInt();
  40. if (!(something<somethingElse)) {
  41. // correct response - system prints out some stuff back to user, back to main
  42. System.out.println("Print here the result");
  43. // menu loop
  44. return;
  45. }
  46. // false response - continue for next iteration in while-loop
  47. }
  48. //No need of 'break;' here
  49.  
  50. case 2:
  51. break;
  52.  
  53. case 5:
  54. System.out.println("\nEnding Now\n");
  55. System.exit(0);
  56.  
  57. default:
  58. System.out.println("Instruction is invalid");
  59. }
  60. } while (selection != 5);
  61. }
  62. }
  63.  
  64. public static void main (String[] args) throws java.lang.Exception
  65. {
  66. StackPost();
  67. }
  68. }
Success #stdin #stdout 0.13s 29400KB
stdin
1 1 5 8 4 6 7
stdout
Welcome to the Bank of Winterfell
1 - Compute Change 

2 - Estimate Feast 

3 - 

4 - 

5 - I'm broke, get me out of here

Select Option:

Print here the result