| 1 | import java.io.BufferedReader; |
| 2 | import java.io.IOException; |
| 3 | import java.io.InputStreamReader; |
| 4 | |
| 5 | public class io |
| 6 | { |
| 7 | int value; |
| 8 | public static BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); |
| 9 | |
Top |
10 | | 10 | public boolean allowedValue() throws IOException |
| 11 | { |
| 12 | System.out.print("Enter a number (0 to quit programm): "); |
| 13 | String mystring = new String(); |
| 14 | mystring = console.readLine(); |
10 | | 15 | try |
| 16 | { |
| 17 | value = Integer.parseInt(mystring.trim()); |
| 18 | |
9 | 1 | 19 | if (value != 0) |
9 | | 20 | return true; |
| 21 | else |
1 | | 22 | return false; |
| 23 | } |
0 | | 24 | catch(NumberFormatException err) |
| 25 | { |
0 | | 26 | return false; |
| 27 | } |
| 28 | } |
| 29 | |
Top |
9 | | 30 | public void test() |
| 31 | { |
4 | 5 | 32 | if (Calc.isPrime(value)) |
| 33 | System.out.println(this.value + " IS a prime"); |
| 34 | else |
| 35 | System.out.println(this.value + " IS NOT a prime"); |
| 36 | } |
| 37 | |
| 38 | } |
| 39 | |