-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguessCount.java
More file actions
32 lines (29 loc) · 1022 Bytes
/
guessCount.java
File metadata and controls
32 lines (29 loc) · 1022 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
32
/**
* Created by fattyduck on 3/23/15.
*/
import java.util.Scanner;
import java.util.Random;
public class guessCount {
public static void main(String[] args){
Scanner scan= new Scanner(System.in);
Random rand=new Random();
int num=rand.nextInt(20);
System.out.println("I have a number in mind from 1-20, try to guess it");
int guess=scan.nextInt();
int times=1;
while(num!=guess){
System.out.println("nope, guess again");
guess=scan.nextInt();
times++;
if(num==guess){
if(times<3){
System.out.println("You are good guesser it only took you "+times+" tries");
}else if(times>3&×<5){
System.out.println("You are decent guesser it took you "+times+" tries");
}else if(times>5){
System.out.println("You are bad guesser it took you "+times+" tries");
}
}
}
}
}