package dice.project;
import java.util.Scanner;
import java.util.Random;
public class DiceProject {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter your number of rolls:");
int count = in.nextInt();
int[]rollDice = new int[count];
Random values = new Random();
for(int m=0; m<count; m++)
{
rollDice[m]=values.nextInt(6)+1;
}
boolean inRun=false;
for(int m=0; m<rollDice.length; m++)
{
if(inRun)
{
if(m>0 && rollDice[m]!=rollDice[m-1])
{
System.out.print(")" + rollDice[m]);
inRun=false;
}
}
if(!inRun)
{
if(m<rollDice.length-1 && rollDice[m]==rollDice[m-1])
{
System.out.print("(" + rollDice[m]);
inRun=true;
}
}
System.out.print(rollDice[m]);
}
if(inRun)
System.out.print("(");
}
}
我的程序有什么问题?当我运行它时,我得到一个异常的东西,它不会工作?
at java.util.Scanner.nextInt(Scanner.java:2166)
at java.util.Scanner.nextInt(Scanner.java:2119)
at dice.project.DiceProject.main(DiceProject.java:20)
这也是我尝试输出时出现的情况?