/**
* @param args the command line arguments
*/
public double averagegrades(double total, double average) {
average = total/5;
return average;
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double[] grades = new double[5];
double total = 0;
double average = 0;
for(int i=0; i<5; i++){
System.out.println("Enter Number: ");
grades[i] = input.nextDouble();
total = total + grades[i];
}
System.out.println("The average is"+average);
}
}
Andrew_70
0
Newbie Poster
Recommended Answers
Jump to PostIt appears you never computed the average. Why not simplify this code.
- Delete lines 1 to 10.
- Delete line 15
- Replace line 22 with System.out.println("The average is"+(total/5));
All 2 Replies
rproffitt
2,580
"Nothing to see here."
Moderator
Andrew_70
commented:
I would, but he would like me to use the method way so I need those lines.
+0
rproffitt
2,580
"Nothing to see here."
Moderator
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.