ユーザーにコインを投げる回数を指定するよう求めるコイン フリッパー プログラムを設計しようとしています (コインを投げる回数は 1000 回未満である必要があります)。次に、1 から 10 までの乱数を取得し、その数値を、ユーザーが求めるフリップの数に基づいて宣言された各配列インデックスに割り当てます。
math.random 行のシンボルを解決できないという 3 つのエラーが発生しているようです。どんな助けでも大歓迎です。
import java.io.*;
import java.util.*;
public class coinFlip {
public static void main(String[] args) throws IOException {
// declare in as a BufferedReader; used to gain input from the user
BufferedReader in;
in = new BufferedReader(new InputStreamReader(System.in));
//declare variables
int flips;
int anArray[];
int x;
int r;
System.out.println("How many times would you like to flip your coin?");
flips = Integer.parseInt(in.readLine());
if(flips <= 1000) {
System.out.println("You want to flip " + flips + " times");
anArray = new int[flips];
for(x = 0; x <= flips; x++) {
r = Math.round(Math.random()*9)+1;
anArray[x] = r;
System.out.println(anArray[x]);
}
}
}
}