-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMiniGame.java
More file actions
31 lines (24 loc) · 808 Bytes
/
MiniGame.java
File metadata and controls
31 lines (24 loc) · 808 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
import java.util.Scanner;
public class MiniGame {
public static void main(String [] args){
Scanner sc=new Scanner(System.in);
int secretKey=42;
int guesser =0;
int count=0;
System.out.println("====Secret Number Guessing Game===");
System.out.println("Try to Guess the Secret Number");
while(guesser != secretKey){
System.out.print("Enter Your Guess:");
guesser=sc.nextInt();
count++;
if(guesser>secretKey){
System.out.println("Too High");
} else if (guesser<secretKey) {
System.out.println("Too Low");
}
else{
System.out.print("Correct! You got this in " + count + "Guesses");
}
}
}
}