|
|
@@ -1,9 +1,47 @@
|
|
1
|
1
|
/**
|
|
2
|
2
|
* Created by iyasuwatts on 10/17/17.
|
|
3
|
3
|
*/
|
|
|
4
|
+import java.util.Scanner;
|
|
|
5
|
+import java.util.Random;
|
|
|
6
|
+
|
|
4
|
7
|
public class Main {
|
|
5
|
8
|
|
|
6
|
9
|
public static void main(String[] args){
|
|
7
|
|
-
|
|
|
10
|
+ Scanner input = new Scanner(System.in);
|
|
|
11
|
+ int randNumb;
|
|
|
12
|
+ int guess;
|
|
|
13
|
+ int numbAtempts=0;
|
|
|
14
|
+ Random genRand = new Random();
|
|
|
15
|
+ randNumb= genRand.nextInt(100) +1;
|
|
|
16
|
+ int lastInput;
|
|
|
17
|
+
|
|
|
18
|
+ System.out.println ("I'm thinking off a number between 1 to 100?:");
|
|
|
19
|
+
|
|
|
20
|
+ guess=input.nextInt();
|
|
|
21
|
+ lastInput=guess;
|
|
|
22
|
+
|
|
|
23
|
+ while (guess !=randNumb ){
|
|
|
24
|
+ if (guess> randNumb){
|
|
|
25
|
+ System.out.println("Your number is too BIG ");
|
|
|
26
|
+ guess=input.nextInt();
|
|
|
27
|
+
|
|
|
28
|
+
|
|
|
29
|
+ numbAtempts+=1;
|
|
|
30
|
+
|
|
|
31
|
+ } else {
|
|
|
32
|
+ System.out.println("Your number is too SMALL");
|
|
|
33
|
+ guess=input.nextInt();
|
|
|
34
|
+ numbAtempts+=1;
|
|
|
35
|
+
|
|
|
36
|
+
|
|
|
37
|
+ }
|
|
|
38
|
+
|
|
|
39
|
+
|
|
|
40
|
+ }
|
|
|
41
|
+
|
|
|
42
|
+ System.out.println(randNumb + " is the right number and it only took you" +" "+ (numbAtempts + 1) + " tries");
|
|
8
|
43
|
}
|
|
|
44
|
+
|
|
|
45
|
+
|
|
9
|
46
|
}
|
|
|
47
|
+
|