|
|
@@ -1,9 +1,26 @@
|
|
1
|
1
|
/**
|
|
2
|
2
|
* Created by iyasuwatts on 10/17/17.
|
|
3
|
3
|
*/
|
|
|
4
|
+import java.util.*;
|
|
4
|
5
|
public class Main {
|
|
5
|
|
-
|
|
6
|
6
|
public static void main(String[] args){
|
|
7
|
|
-
|
|
8
|
|
- }
|
|
9
|
|
-}
|
|
|
7
|
+ Scanner keyboard = new Scanner(System.in);
|
|
|
8
|
+ boolean isCorrect = false;
|
|
|
9
|
+ int n=0;
|
|
|
10
|
+ while(isCorrect==false) {
|
|
|
11
|
+ System.out.println("Guess a mystery number!");
|
|
|
12
|
+ int randNumber=(int)(Math.random()*10+1);//generating a random number
|
|
|
13
|
+ int number = keyboard.nextInt();//user input
|
|
|
14
|
+ if(number == randNumber) {
|
|
|
15
|
+ System.out.println("correct guess");
|
|
|
16
|
+ isCorrect = true;
|
|
|
17
|
+ }else if(number>=randNumber){
|
|
|
18
|
+ System.out.println("too large");
|
|
|
19
|
+ } else{
|
|
|
20
|
+ System.out.println("too small");
|
|
|
21
|
+ }
|
|
|
22
|
+ n++;
|
|
|
23
|
+ }
|
|
|
24
|
+ System.out.println(n);
|
|
|
25
|
+ }
|
|
|
26
|
+}
|