import java.util.*;
public class Testing {
public static void main(String[] args) {
Random rand = new Random();
int random = (int)(Math.random() * 3 + 1);
//to see what number to guess
System.out.println(random);
int score = 0;
Scanner input = new Scanner(System.in);
System.out.print("Enter Number: ");
String num = input.nextLine();
int count = 0;
while (count <= 5)
{
if(random == 1)
{
if(num.equals("one"))
{
System.out.println("correct");
score++;
}
else
{
System.out.print("Wrong!");
}
}
else if(random == 2)
{
if(num.equals("two"))
{
System.out.println("correct");
score++;
}
else
{
System.out.print("Wrong!");
}
}
else
{
if(num.equals("three"))
{
System.out.println("correct");
score++;
}
else
{
System.out.print("Wrong!");
}
}
count++;
}
System.out.println(score);
}
}
How do I make it that will ask 5 different random numbers. For every good guess, there will be +1 score? Good/bad guess, it will proceed to another random number?
Aucun commentaire:
Enregistrer un commentaire