Java program to find average of N number

Java program to find average

Java program to find average of 5 number

Java program to find average of 10 number

Java program to find average without using array

Program:-

import java.util.Scanner;
class group{
public static void main(String arng[]){
Scanner data = new Scanner(System.in);
int i, num, temp = 0;
float sum = 0;
System.out.print("How may numbers you want take average: ");
num=data.nextInt();
System.out.println("Enter " +num+ " for average");
for(i=0; i < num; i++)
{
temp = data.nextInt();
sum = sum + temp;
}
sum = sum/num;
System.out.println("Average of " +num+ " is "+sum);
}
}

Output:-

How may numbers you want take average: 4
Enter 4 for average
5
6
7
8
Average of 4 is 6.5


Learn Java:-
Java codes

Java Programs:-
List of Java Programs

5 Comments

  1. could you show how to find average of n numbers and then find the numbers above the average?

    ReplyDelete

  2. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to article very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
    DedicatedHosting4u.com

    ReplyDelete
  3. Thank you for such a informative information.It will really helpfull for beginer to know the basic difference between linux and windows hosting.

    Thanks
    Cpa offers

    ReplyDelete

  4. This is a fantastic idea! I like it a lot because it's super easy for the audience to see the value of opting in. wonderful and amazing post very use full your post thanks for sharing your article
    Android Application development
    Web application

    ReplyDelete

  5. Your post is very good. I got to learn a lot from your post. Thank you for sharing your article for us. it is amazing post
    what is seo
    types of seo

    ReplyDelete

Add your comments here

Back to Top