|
@@ -1,9 +1,42 @@
|
|
1
|
+import java.util.*;
|
1
|
2
|
/**
|
2
|
3
|
* Created by iyasuwatts on 10/17/17.
|
3
|
4
|
*/
|
4
|
5
|
public class Main {
|
5
|
|
-
|
|
6
|
+ int guessNumber;
|
|
7
|
+ public static Scanner input;
|
|
8
|
+
|
6
|
9
|
public static void main(String[] args){
|
|
10
|
+
|
|
11
|
+ System.out.println("!!!****Guessing Game****!!!");
|
|
12
|
+ int gameNumber = (int)Math.random() *10+1;
|
|
13
|
+
|
|
14
|
+ input = new Scanner(System.in);
|
|
15
|
+ System.out.println("Guess a number between 10!");
|
7
|
16
|
|
|
17
|
+ compareNumbers(gameNumber,setGuessNumber());
|
|
18
|
+
|
|
19
|
+ }
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+ public static int setGuessNumber(){
|
|
23
|
+
|
|
24
|
+ return input.nextInt();
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+ public static void compareNumbers(int gameNumber, int guessNumber){
|
|
28
|
+
|
|
29
|
+ if(guessNumber == gameNumber)
|
|
30
|
+ System.out.println("Congrats! You won");
|
|
31
|
+
|
|
32
|
+ else if(guessNumber < gameNumber){
|
|
33
|
+ System.out.println("Oops! That number is too small. Try Again!");
|
|
34
|
+ compareNumbers(gameNumber,setGuessNumber());
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ else{
|
|
38
|
+ System.out.println("OOps! That number is too large. Try Again!");
|
|
39
|
+ compareNumbers(gameNumber,setGuessNumber());
|
|
40
|
+ }
|
8
|
41
|
}
|
9
|
42
|
}
|