【发布时间】:2013-11-08 04:50:58
【问题描述】:
我正在尝试将 2 个数组相加并获得总和的平均值 我该怎么做呢?我也想在数组中生成答案。
public static void part1 (){
double examMarks [] = {50,40,60,80,70,11};
double courseworkmarks [] = {65,49,58,77,35,40};
System.out.println ("These are the exam marks and the course work marks");//First row is the exam marks, second row is the course work marks
computeMarks (examMarks);
computeMarks1 (courseworkmarks);
}
public static void computeMarks(double[] examMarks)
{
for (int row=0;row<examMarks.length;row++){
System.out.print (examMarks[row] +"\t");
}
System.out.println();
}
public static void computeMarks1(double[] courseworkmarks)
{
for (int row=0;row<courseworkmarks.length;row++){
System.out.print (courseworkmarks[row] +"\t");
}
System.out.println();
}
【问题讨论】:
-
我正在尝试添加考试成绩和课程成绩。请注意,我需要添加第一列,然后获取平均值和第二列,然后获取平均值。所以 50+65、40+49、60+58 等等。
-
您的解决方案现在有什么问题?
标签: java arrays eclipse average