Write a program to receive ten floating points value,store them in an array. Then calculate and display their average.
import java.util.*;
class App {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
double[] numbers = new double[10];
for (int i = 0; i < 10; i++) {
System.out.print("Enter number: ");
numbers[i] = keyboard.nextDouble();
}
double sum = 0;
for (int i = 0; i < 10; i++) {
sum += numbers[i];
}
double average = sum / 10.0;
System.out.println("Average: " + average);
keyboard.close();
}
}
Comments
Leave a comment