public class Main {
public static void main(String[] args) {
java.util.ArrayList<StudentDataArray> info = new java.util.ArrayList<StudentDataArray>();
int amountOfPeople = KeyboardInput.promptForInt("Enter how many people you plan to enter into the list.");
for(int a=0;a<amountOfPeople;a++) {
try {
double[] grade = new double[5];
grade[0]=KeyboardInput.promptForDouble("Enter the First grade");
grade[1]=KeyboardInput.promptForDouble("Enter the Second grade");
grade[2]=KeyboardInput.promptForDouble("Enter the Third grade");
grade[3]=KeyboardInput.promptForDouble("Enter the Fourth grade");
grade[4]=KeyboardInput.promptForDouble("Enter the Fifth grade");
info.add(new StudentDataArray(KeyboardInput.promptForString("Enter the First Name"),KeyboardInput.promptForString("Enter the Last Name"),grade,KeyboardInput.promptForChar("Enter the Final Grade")));
}catch(IllegalArgumentException e){
System.out.println("Hello World :)");
}
}
for(int b=0;b<amountOfPeople;b++) {
System.out.printf("%-10s %-10s %-3f %-3s",info.get(b).getFN(),info.get(b).getLN(),info.get(b).getTS(),info.get(b).getFG());
}
}
}
public class StudentDataArray {
private String firstName;
private String lastName;
private double[] testScore;
private char finalGrade;
public StudentDataArray(String FN, String LN, double[] TS, char FG) {
firstName = FN;
lastName = LN;
testScore = TS;
finalGrade = FG;
}
public void setFN(String FN) {firstName = FN;};
public void setLN(String LN) {lastName = LN;}
public void setTS(double[] TS) {testScore = TS;}
public void setFG(char FG) {finalGrade = FG;}
public String getFN() {return firstName;};
public String getLN() {return lastName;}
public String getTS() {
for(int a=0;a<testScore.length;a++) {
return testScore[a]+" ";
}
return null;
}
public char getFG() {return finalGrade;}
}
大家好,这是我的代码供大家查看。我想要做的是将多个双打返回到代码中的一个位置。它会是什么样子...
伊桑迈克尔 10 20 30 40 50 A
这都显示在一个语句中 [10 20 30 40 50]
由于我使用的是 double[] 我不知道该怎么做。
多谢你们!