Java program to find average of n numbers
// Java program to find average of n numbers import java.util.Scanner; public class FindAverageOfNNumbers { public static void main(String[] args) { int num, count = 1; float a, average, total = 0; Scanner sc = new Scanner(System.in); System.out.println("Please enter n numbers: "); num = sc.nextInt(); while(count <= num) { System.out.println(count + " number: "); a = sc.nextInt(); total += a; ++count; } average = total / num; System.out.println("Average is: " + average); sc.close(); } }