|
@@ -1,9 +1,40 @@
|
1
|
1
|
/**
|
2
|
2
|
* Created by iyasuwatts on 10/17/17.
|
3
|
3
|
*/
|
|
4
|
+import java.util.Scanner;
|
4
|
5
|
public class Main {
|
5
|
6
|
|
6
|
7
|
public static void main(String[] args){
|
7
|
|
-
|
|
8
|
+ int num = (int)((Math.random()*10)%20)+1;
|
|
9
|
+ //System.out.println(num);
|
|
10
|
+ System.out.println("Guess a number between 1 and 20");
|
|
11
|
+ int currentGuess;
|
|
12
|
+ int previousGuess =0;
|
|
13
|
+ int numGuess =0;
|
|
14
|
+ Boolean guess = true;
|
|
15
|
+
|
|
16
|
+ while (guess){
|
|
17
|
+ Scanner in = new Scanner(System.in);
|
|
18
|
+ currentGuess = in.nextInt();
|
|
19
|
+
|
|
20
|
+ if (currentGuess == num){
|
|
21
|
+ System.out.println("Correct Guess");
|
|
22
|
+ guess = false;
|
|
23
|
+ }
|
|
24
|
+ else if (currentGuess > num){
|
|
25
|
+ System.out.println("too large");
|
|
26
|
+
|
|
27
|
+ }
|
|
28
|
+ else {
|
|
29
|
+ System.out.println("too small");
|
|
30
|
+
|
|
31
|
+ }
|
|
32
|
+ if(!(previousGuess == currentGuess)){
|
|
33
|
+ numGuess++;
|
|
34
|
+ }
|
|
35
|
+ previousGuess = currentGuess;
|
|
36
|
+ // i++;
|
|
37
|
+ }
|
|
38
|
+ System.out.println(numGuess);
|
8
|
39
|
}
|
9
|
40
|
}
|