-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShotHiLo.java
34 lines (30 loc) · 896 Bytes
/
ShotHiLo.java
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
33
34
import java.util.Scanner;
import java.util.Random;
public class ShotHiLo {
public static void main(String[]args)
{
Scanner enter = new Scanner(System.in);
Random r = new Random();
int pick = 1 + r.nextInt(100);
String output = " ";
System.out.println("I'm thinking of a number between 1 - 100. Try to guess it.");
pick = enter.nextInt();
if(pick == 42)
{
output = "You guessed it! What are the odds?!?";
}
else if(pick < 34)
{
output = "Sorry you are too low. I was thinking of 34";
}
else if(pick > 51)
{
output = "Sorry you are too high. I was thinking of 51";
}
else
{
output = "Out of bound";
}
System.out.println("\n" + output);
}
}