我需要帮助..我需要存储标准值以供以后使用.. 例如..我输入
和
然后程序会询问
我知道如何完成剩下的工作,但我不知道如何将Criteria值存储起来用于其余的评分性能。
System.out.println("How many criteria?");
System.out.print("Answer: ");
crit1=Integer.parseInt(inpt.readLine());
String critr;
int perc;
for(int crit=1; crit<=crit1; crit++){
if(crit1==1){
System.out.println("Criteria(1): ");
critr=inpt.readLine();
System.out.println("Percentage: 100%");
perc=100;
}
System.out.print("Criteria("+ crit +"): ");
critr=inpt.readLine();
System.out.println("Input between 1-100 only");
System.out.print("Percentage: ");
perc=Integer.parseInt(inpt.readLine());
}
int grade;
for(int name1=1; name1<=stud; name1++){
System.out.println("Student's Name: ");
name=inpt.readLine();
System.out.println("Grade for " +critr+": ");
grade=Integer.parseInt(inpt.readLine());
}
是的,这是一项学校工作,我真的需要帮助。我希望你能帮助我。 提前致谢!美好的一天。
答案 0 :(得分:0)
创建一个自定义类的数组来存储数据
class Criteria {
public Criteria (String name, float weight) {
this.name = name;
this.weight = weight;
}
public String name;
public float weight
}
System.out.println("How many criteria?");
System.out.print("Answer: ");
int critCount =Integer.parseInt(inpt.readLine());
Criteria[] sections = new Criteria[critCount];
for(int crit=0; crit < critCount; crit++){
System.out.println("Criteria(1): ");
String name = inpt.readLine();
System.out.println("Percentage: 100%");
float value = Float.parseFloat(inpt.readLine());
sections[i] = new Criteria(name, value);
}
// ...