-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguessNumber
More file actions
24 lines (20 loc) · 791 Bytes
/
Copy pathguessNumber
File metadata and controls
24 lines (20 loc) · 791 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
// Add your import statement here! 💖
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// Add your code here! 💖
Random rand = new Random();
Scanner scan = new Scanner(System.in);
System.out.println("Digite um número de 1 ~ 10: ");
int number = scan.nextInt();
int guess = rand.nextInt(number) + 1;
while (number != guess){
System.out.println("O número sorteado foi: " + guess + "\nVocê não acertou!\n");
System.out.println("Tente novamente: ");
number = scan.nextInt();
guess = rand.nextInt(number) + 1;
}
System.out.println("O número sorteado foi: " + guess + "\nVocê acertou!");
}
}