Print average of n numbers.

Share code with your friends

Share on whatsapp
Share on facebook
Share on twitter
Share on telegram


import java.util.Scanner;  
public class AverageOfNNUmbers
   public static void main(String[] args)  
      int n, count = 1;   
      double x, average, sum = 0;   
      Scanner sc = new Scanner(;     
      System.out.println("Enter the value of n");  
      n = sc.nextInt();  
      while (count <= n)   
                  System.out.println("Enter the "+count+" number?");  
                  x = sc.nextInt();  
                  sum += x;   
                  average = sum/n;   
        System.out.println("The Average is"+averageF);  


Coding Store

Leave a Reply

Your email address will not be published. Required fields are marked *