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. Scanner input = new Scanner(System.in);
  13. System.out.print("Enter the minimum number: ");
  14. int min = input.nextInt();
  15. System.out.print("Enter the maximum number: ");
  16. int max = input.nextInt();
  17. System.out.print("Enter the value: ");
  18. int value = input.nextInt();
  19. while (value < min || value > max) {
  20. System.out.printf("Oops, %s is not between %s and %s.\n", value, min, max);
  21. System.out.print("Enter the value: ");
  22. value = input.nextInt();
  23. }
  24. System.out.printf("You did it, %s is between %s and %s!\n", value, min, max);
  25. }
  26. }
Success #stdin #stdout 0.1s 380736KB
stdin
2
4
1
3
stdout
Enter the minimum number: Enter the maximum number: Enter the value: Oops, 1 is not between 2 and 4.
Enter the value: You did it, 3 is between 2 and 4!