Enums java:61:错误:应为类、接口或枚举
代码如下:Enums java:61:错误:应为类、接口或枚举,enums,Enums,代码如下: /*Purpose of program: • To demonstrate creating a Student class and creating and using a Student object • To demonstrate creating arrays and initializing the array from a data file • To demonstrate various ways to utilize arrays */ public c
/*Purpose of program:
• To demonstrate creating a Student class and creating and using a Student object
• To demonstrate creating arrays and initializing the array from a data file
• To demonstrate various ways to utilize arrays
*/
public class StudentGrades
{ //fields
private int idNum; //1 number to refernce student from list
private int[] scores = new int[10]; //2 test grades
//constructor, accepts args(for fields?)
public StudentGrades(int mIdNum, int[] mScores)
{
idNum = mIdNum;
scores = mScores;
}
//(no-args constructor)
public StudentGrades()
{
idNum = 0;
scores = 0;
}
//methods (sets~ accept args)(gets~ return)
public void setIdNum(int mIdNum) //1 //allows value change of field after object creation
{
idNum = mIdNum;
}
public int getIdNum()
{
return idNum;
}
public void setScores(int mScores) //2
{
scores = mScores;
}
public int getScores()
{
return scores;
}
public int calculateTotalScores() //method calculates total of test grades
{
totalScores = totalScores + scores;
return totalScores;
}
public int calculateAdjustedTotalScores() //method calculates adjusted total (drop lowest, use highest twice)
{
lowest = scores[0];
highest = scores[ ];
total = 0;
for(int c=1; c<scores.length; c++)
if(lowest >scores[c])
{
lowest = scores[c]
}
if(highest <scores[c])
{
highest = scores[c]
}
AdjustedTotalScores = total + lowest - highest
}
// public int calculateTotalScores() //method calculates average of ten grades (base upon adjusted total, round to the nearest int)
}
java:57:错误:应为类、接口或枚举
public int[] calculateAdjustedTotalScores() //method calculates adjusted total (drop lowest, use highest twice)
^
highest = scores[ ];
^
total = 0;
^
for(int c=1; c<scores.length; c++)
^
for(int c=1; c<scores.length; c++)
^
for(int c=1; c<scores.length; c++)
^
java:60:错误:应为类、接口或枚举
public int[] calculateAdjustedTotalScores() //method calculates adjusted total (drop lowest, use highest twice)
^
highest = scores[ ];
^
total = 0;
^
for(int c=1; c<scores.length; c++)
^
for(int c=1; c<scores.length; c++)
^
for(int c=1; c<scores.length; c++)
^
java:61:错误:应为类、接口或枚举
public int[] calculateAdjustedTotalScores() //method calculates adjusted total (drop lowest, use highest twice)
^
highest = scores[ ];
^
total = 0;
^
for(int c=1; c<scores.length; c++)
^
for(int c=1; c<scores.length; c++)
^
for(int c=1; c<scores.length; c++)
^
java:62:错误:应为类、接口或枚举
public int[] calculateAdjustedTotalScores() //method calculates adjusted total (drop lowest, use highest twice)
^
highest = scores[ ];
^
total = 0;
^
for(int c=1; c<scores.length; c++)
^
for(int c=1; c<scores.length; c++)
^
for(int c=1; c<scores.length; c++)
^
我不理解compliler.1的错误响应。缩进代码。2.当您声明一个方法返回一个
int
-它应该返回一个int
;)