-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuessing_Number.java
More file actions
50 lines (23 loc) · 1.03 KB
/
Guessing_Number.java
File metadata and controls
50 lines (23 loc) · 1.03 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.Scanner;
public class Guessing_Number{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int min = 0;
int max = 10;
int rand_num = (int) (min + Math.random() * (max - min + 1));
int guess = 9000;
System.out.print("Guess a number: ");
while (guess != rand_num){
guess = input.nextInt();
if (guess < rand_num){
System.out.println("guess is low!");
System.out.print("Guess a number: ");
}
else if (guess > rand_num){
System.out.println("guess is High!");
System.out.print("Guess a number: ");
}
}
//System.out.println(rand_num);
}
}