我有一项家庭作业,其中一名潜水员由7名法官评判。评委的得分是1.0-10.0。最高和最低分数被抛出,其余分数相加。然后,总和乘以潜水的难易程度,范围为1.2-3.8分。然后,将总数乘以0.6得到最终分数。
我的程序必须包括其他4个都具有返回值的方法:
-inputValidScore,为一位法官输入一个有效分数
-inputAllScores,它创建一个数组来存储法官的有效分数,并将返回分数数组(不使用输入参数)
-inputValidDegreeOfDifficulty,输入难度有效
-calculateScore,它将根据指示计算总数
*不允许我使用Java库中包含的任何数组类或数组方法。 *
我的问题是,我不确定如何从主方法的for循环中输入的值放入由另一方法生成的数组中。
public static void main(String[] args) {
double degree, tempScore, sum, x, y , total;//extras if needed
Scanner input = new Scanner (System.in);
System.out.println("What is the degree: ");
degree = input.nextDouble();
double diff = degreeOfDifficulty(degree);
double [] scoreList = new double [7];
for(double i = 0; i<scoreList.length; i++){
System.out.println("# " + ((int)(i + 1)) + " score: ");
tempScore = input.nextDouble();
}
}
public static double degreeOfDifficulty(double someDegree){
Scanner input = new Scanner (System.in);
while(someDegree<1.2 || someDegree>3.8){
System.out.print("Please enter a valid number");
someDegree = input.nextDouble();
}
return someDegree;
}
public static double inputValidScore(double someScore){
Scanner input = new Scanner (System.in);
while(someScore<1.0 || someScore>10.0){
System.out.print("Please enter a valid number");
someScore = input.nextDouble();
}
return someScore;
}
public static double[] inputAllScores(double someList){
someList[] = new double [someList.length];
}