fork download
  1. import java.util.Scanner;
  2. import java.io.*;
  3.  
  4. public class Main{
  5. static boolean check_number(int choice)
  6. {
  7.  
  8. Scanner read = new Scanner(System.in);
  9. try{
  10. choice = Integer.parseInt(read.nextLine());
  11. } catch(Exception e){
  12. System.out.println("Choice have to been integer, bigger than 0");
  13. }
  14. read.close();
  15. return choice == 0?false:true;
  16.  
  17. }
  18.  
  19. public static void main(String[] args)
  20. {
  21. int choice = 0;
  22. boolean check=false;
  23.  
  24.  
  25. System.out.println("Choose option:");
  26. System.out.println("1. Adding, multiplication, subtraction, division");
  27. while(!check)
  28. {
  29. check = check_number(choice);
  30. System.out.println(choice);
  31. }
  32. }
  33. }
Success #stdin #stdout 0.14s 321344KB
stdin
1
stdout
Choose option:
1. Adding, multiplication, subtraction, division
0