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

6 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
  6. I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts. Python Projects for Students Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account. Project Center in Chennai

    ReplyDelete

Add your comments here

Back to Top