We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 13d6a85 commit 3ced69fCopy full SHA for 3ced69f
Number Guessing Game.java
@@ -0,0 +1,20 @@
1
+import java.util.*;
2
+
3
+public class GuessGame {
4
+ public static void main(String[] args) {
5
+ Random r = new Random();
6
+ int num = r.nextInt(100) + 1;
7
8
+ Scanner sc = new Scanner(System.in);
9
+ int guess = 0;
10
11
+ while (guess != num) {
12
+ System.out.print("Guess number (1–100): ");
13
+ guess = sc.nextInt();
14
15
+ if (guess < num) System.out.println("Too low!");
16
+ else if (guess > num) System.out.println("Too high!");
17
+ else System.out.println("Correct!");
18
+ }
19
20
+}
0 commit comments