-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathMain.java
More file actions
39 lines (32 loc) · 1002 Bytes
/
Main.java
File metadata and controls
39 lines (32 loc) · 1002 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
38
39
import java.util.Scanner;
/**
* Created by iyasuwatts on 10/17/17.
*/
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int myNum = (int)(Math.random() * 100);
int currentNum = 0;
int count = 0;
int num = in.nextInt();
while (myNum != num){
if (num > myNum && num != currentNum){
currentNum = num;
System.out.println("Too high. Go Smaller");
count = count + 1;
num = in.nextInt();
} else if (num < myNum && num != currentNum){
currentNum = num;
System.out.println("Too small. Bigger");
count = count + 1;
num = in.nextInt();
} else if (num == currentNum){
System.out.println("You put the same number again");
num = in.nextInt();
}
}
if (num == myNum){
System.out.println("You got it. Took you " + count + " tries");
}
}
}