在学习如何使用 tpass 参数时,我遇到了一个问题,我无法弄清楚程序显示错误的原因。我将突出显示下面的代码。
public class pkgExone
{
static void displayMarkRange(int[] ref,double[] mark, double size,double topValue,
double bottomValue, String message)
{
int index; //declare a variable index
System.out.println("\n\n"+ message+"\n\n"); //print parameter message
System.out.println("Reference \t Mark ");
System.out.println("Number \t Obtained\n");
// loop through the whole array and decide whether to print a students mark
for(index=0;index<=size-1;index=index+1)
{
if ((mark[index]>= bottomValue) && (mark[index]<=topValue))
{
System.out.println( ref[index]+" \t\t\t"+ mark[index]);
} // end if construct
} // end for loop
System.out.println("\n\n");
} // end of displayMarkRangeMethod
static double Calaverage(double [] mark, double size)
{
int index;
double total=0;
double calculatedaverage;
int validentries=0;
for (index=0;index<=size-1;index ++)
if ((mark[index]>=1) && (mark [index] <=100))
{
**double total + mark [index];
int validentries= validentries +1;**
}
**double calculatedaverage = total/validentires;**
return calculatedaverage;
}
public static void main(String[] args)
{
double [] ref;
double Averagemark;
double howMany=10;
int[] studentID = {900,901,902,903,904,905,906,907,908,909};
double[] examMark = {23,45,56,90,83,114,48,39,26,102};
displayMarkRange(studentID,examMark,howMany,100,1,"All Students that have valid marks");
displayMarkRange(studentID,examMark,howMany,100,70,"All Distinction students");
displayMarkRange(studentID,examMark,howMany,69,55,"All Merit students");
displayMarkRange(studentID,examMark,howMany,54,40,"All Pass students");
displayMarkRange(studentID,examMark,howMany,39,1,"All Fail students");
displayMarkRange(studentID,examMark,howMany,69,40,"All Pass or Merit students");
displayMarkRange(studentID,examMark,howMany,100,90,"Student that got between 90 and 100");
displayMarkRange(studentID,examMark,howMany,10,1,"Student that got between 10 and 1");
displayMarkRange(studentID,examMark,howMany,80,20,"Student that got between 80 and 20");
displayMarkRange(studentID,examMark,howMany,100,**Averagemark**,"Students that got more than the average");
displayMarkRange(studentID,examMark,howMany,Averagemark,1,"Students that got less than the average");
displayMarkRange(studentID,examMark,howMany,120,101,"Students whos marks are invalid");
}// end of psvm
}//end of public class
当我编译文件时:
Updating property file: H:\PIJOOP\ProjectSectionEleven\build\built-jar.properties
Compiling 1 source file to H:\PIJOOP\ProjectSectionEleven\build\classes
H:\PIJOOP\ProjectSectionEleven\src\projectsectioneleven\pkgExone.java:42: error: ';' expected
double total + mark [index];
H:\PIJOOP\ProjectSectionEleven\src\projectsectioneleven\pkgExone.java:42: error: not a statement
double total + mark [index];
2 errors
H:\PIJOOP\ProjectSectionEleven\nbproject\build-impl.xml:628: The following error occurred while executing this line:
H:\PIJOOP\ProjectSectionEleven\nbproject\build-impl.xml:246: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)