-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2-TheNum.java
More file actions
37 lines (33 loc) · 736 Bytes
/
2-TheNum.java
File metadata and controls
37 lines (33 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Question
/*Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely… rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.
Sample Input:
1
2
88
42
99
Sample Output:
1
2
88*/
//Solution
import java.util.*;
import java.lang.*;
import java.io.*;
class Sol
{
public static void main (String[] args) throws java.lang.Exception
{try{
Scanner scan = new Scanner(System.in);
while(true){
int value = scan.nextInt();
if(value == 42 ){
break;
}
System.out.println(value);
}
}catch(Exception e){
return;
}
}
}