-
Notifications
You must be signed in to change notification settings - Fork 0
/
GuessGame.java
32 lines (23 loc) · 974 Bytes
/
GuessGame.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
import java.util.Random;
import java.util.Scanner;
public class GuessGame {
public static void main(String[] args) {
Random random=new Random();
int number=random.nextInt(100);
Scanner sc=new Scanner(System.in);
System.out.println("Guess the Number by Entering Integer value : ");
int input=sc.nextInt();
while(number != input){
if(number < input){
System.out.println("Your guessed number is higher than actual 'Please enter small number!' ");
input=sc.nextInt();
}else if(number > input){
System.out.println("Your guessed number is smaller than actual 'Please enter large number!' ");
input=sc.nextInt();
}
}
System.out.println("*****Congratulations!!!*****");
System.out.println("You Guess the correct ");
sc.close();
}
}