介意看看这段代码吗?它给了我一个错误,我不知道该怎么做。它的课程和任何帮助将不胜感激。我必须制作一个随机生成的三位数号码的彩票程序,然后用户可以在多种组合中获胜。请参阅代码以进行说明。
import java.util.Scanner;
public class Lottery
{
public static void main(String[] args)
{
//declare and initialized variables and objects
Scanner in = new Scanner(System.in);
String lotteryNum = "";
String userGuess = "";
for(int tries = 0; tries >= 0; tries++)
{
int randomNum1 = (int)(Math.random() * 10);
int randomNum2 = (int)(Math.random() * 10);
int randomNum3 = (int)(Math.random() * 10);
int computerNum1 = getNumericValue (randomNum1.charAt(0) );
int computerNum2 = getNumericValue (randomNum2.charAt(1) );
int computerNum3 = getNumericValue (randomNum3.charAt(2) );
String randomNum = "" + randomNum1 + randomNum2 + randomNum3;
System.out.print("Please enter three numbers:");
int num1 = in.nextInt();
int num2 = in.nextInt();
int num3 = in.nextInt();
if (num1 == computerNum1 && num2 == computerNum2)
{
System.out.println("You win!");
}
else if (num2 == computerNum2 && num3 == computerNum3)
{
System.out.println("You Win!");
}
else if (num1 == computerNum1 && num2 ==computerNum2 && num3 == computerNum3)
{
System.out.println("Sorry, You Lost");
}
}}}