-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathMain.java
More file actions
37 lines (27 loc) · 915 Bytes
/
Main.java
File metadata and controls
37 lines (27 loc) · 915 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
/**
* Created by iyasuwatts on 10/17/17.
*/
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Guess a number between 1 and 20 Clark:");
int guess = in.nextInt();
int theNum = (int) (Math.random() * 20 + 1);
int count = 1;
int previous = 0;
while (guess != theNum) {
if (guess > theNum) {
System.out.println("too large");
} else if (guess < theNum) {
System.out.println("too small");
} else if (guess == previous){
count --;
}
previous = guess;
count ++;
System.out.println("Guess again Rusty");
guess = in.nextInt();
} System.out.println("correct guess it took you " + count + "guesses");
}
}