0

Hi,

I have recently started Java in my course and I have been asked to write a program that finds the sum and average of 5 numbers.

Its very close to working correctly but I cannot see where I am going wrong.

Code:

```
import java.util.Scanner;
public class average {
static int i=0;
static double sum = 0;
static double average = 0;
public static double calcSum(double sum){
double count;
Scanner input = new Scanner(System.in);
while(i < 5){
count = input.nextDouble();
sum = sum + count;
i++;
}
return sum;
}
public static double calcAverage(double average){
double sum = calcSum(sum);
average = calcSum(sum) / 5;
return average;
}
public static void main(String[] args) {
System.out.println("Please enter 5 numbers.");
System.out.println("Sum is: "+calcSum(sum));
System.out.println("Average is: "+calcAverage(average));
}
}
```

Any help would be appriciated :).