JAVA
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
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
int num = (int)(Math.random() * 10);
System.out.print("Enter A Number: ");
System.out.print("Try to get the highest score");
Scanner scn = new Scanner(System.in);
int score = 10;
int user = scn.nextInt();
while(user!=num){
System.out.println("\nwrong guess...");
System.out.print("Enter Another Number: ");
user = scn.nextInt();
score = score -1;
}
System.out.println("\nYes you guessed correctly!! the number was ..."+num+"\nyour score was..."+score);
}
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Exécuter