配列の各要素をテキスト ファイルに書き込みたい。たとえば、以下はより明確に示します
String[] Name = {"Eric","Matt","Dave"}
Int[] Scores = {[45,56,59,74],[43,67,77,97],[56,78,98,87]}
double[] average = {45.7,77.3,67.4}
テキストファイルに以下が欲しい
Student Eric scored 45,56,59,74 with average of 45.7
Student Matt scored 43,67,77,97 with average of 77.3
Student Dave scored 56,78,98,87 with average of 67.4
出力ファイルを作成しました
PrintStream output = new PrintStream(new File("output.txt"));
forループを使用しました
for(int i =0;i<=Name.length;i++){
output.println("Student " + Name[i] + " scored " + Scores[i] + " with average of " + average[i]);
}
しかし、これはうまくいきませんでした。助けてください。