新手,求指导!为什么编译出错?
class Calculator{
int sum=0,max,min;
float average=0;
public void calculating(int numbers[]){
if(numbers[0]<numbers[1]){
max=numbers[1];
min=numbers[0];
}
else{
max=numbers[0];
min=numbers[1];
}
sum+=numbers[0];
sum+=numbers[1];
for(int i=2;i<numbers.length;i++){
sum+=numbers[i];
if(numbers[i]>max)
max=numbers[i];
if(numbers[i]<min)
min=numbers[i];
}
average=((float)sum)/numbers.length;
}
public float getAverage(){
return average;
}
public int getMax(){
return max;
}
public int getMin(){
return min;
}
}
public class caculatorTest{
public static void main(String args[]){
int numbers[]={23,54,88,65,56,45,34,21,22,45,43};
Calculator CA=new Calculator();
CA.calculating(numbers);
System.out.println("The aversge is"+CA.getAverage());
System.out.println("The max is"+CA.getMax());
System.out.println("The min is"+CA.getMin());
}
}
编译时出现如图提示,不知道哪里不对啊?谢谢指导!
int sum=0,max,min;
float average=0;
public void calculating(int numbers[]){
if(numbers[0]<numbers[1]){
max=numbers[1];
min=numbers[0];
}
else{
max=numbers[0];
min=numbers[1];
}
sum+=numbers[0];
sum+=numbers[1];
for(int i=2;i<numbers.length;i++){
sum+=numbers[i];
if(numbers[i]>max)
max=numbers[i];
if(numbers[i]<min)
min=numbers[i];
}
average=((float)sum)/numbers.length;
}
public float getAverage(){
return average;
}
public int getMax(){
return max;
}
public int getMin(){
return min;
}
}
public class caculatorTest{
public static void main(String args[]){
int numbers[]={23,54,88,65,56,45,34,21,22,45,43};
Calculator CA=new Calculator();
CA.calculating(numbers);
System.out.println("The aversge is"+CA.getAverage());
System.out.println("The max is"+CA.getMax());
System.out.println("The min is"+CA.getMin());
}
}