-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
32 lines (25 loc) · 769 Bytes
/
Main.java
File metadata and controls
32 lines (25 loc) · 769 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
/**
* @exercise: Adivinhação
* @author: Rodrigo Andrade
* @date: 25 Feb 2026
* @license: MIT
* @language: Java
* @github: https://github.com/Rorchive/C06
*/
package com.rodrigoandrade;
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Random rand = new Random();
// Generates a random number between 1 and 10
int randomNumber = rand.nextInt(10) + 1;
System.out.println("Choose a number between 1 and 10:");
while (input.nextInt() != randomNumber) {
System.out.println("Wrong! Choose again.");
}
System.out.println("Uhuuu! You chose right.");
input.close();
}
}