编写一个完整的 Java 程序,构建一个虚构的成绩册并将其打印到命令行。成绩簿数据必须构造为 10 行的多维数组。每行有六个元素:第一个位置的学生姓名、四个作业分数和最后一个位置的作业平均值。作业分数由第二种方法产生(返回),该方法使用 Math.random() 和数字缩放来产生 0-100 之间的数字。平均值是根据四个分配值计算的。您的程序应至少包含三种方法,每种方法都完成部分工作。这是我的代码:
public static void main(String[] args) {
// TODO code application logic here
gradebook();
}
public static void gradebook(){
findingNumbers();
final int NAMES = 6;
final int ASSIGNMENTS = 4;
String [] names ={"Mike", "Jayson", "Ben","Luke", "Chris", "Joseph"};
System.out.println("Name Assign 1 Assign 2 Assign 3 Assign 4 Average");
for (int i = 0; i < NAMES; i++){
System.out.printf("%10s", names[i]);
double total = 0;
double average = 0;
for (int j = 0; j < ASSIGNMENTS; j++){
for(int k = 0; k < ASSIGNMENTS; k++){
int[] assingments = new int[4];
assingments[k] =(int) (Math.random()*100);
}
System.out.printf("%8d", assingments[i][j]);
total = total + assingments[i][j];
average = total/4;
}
System.out.printf("%2d", average);
}
}
public static double findingNumbers(){
double randomNumber = 0;
randomNumber = Math.random();
randomNumber = randomNumber *100;
int randomInteger = 0;
randomInteger = (int) randomNumber;
return randomInteger;
}
}