How can write Java Average and Above Average | Sololearn: Learn to code for FREE!

+1

# How can write Java Average and Above Average

Write a java program that reads ten numbers, computes their average, and finds out how many numbers are above the average.

2/5/2021 3:53:16 PM

تركي الشهري

+1

https://code.sololearn.com/cqSifWp47kKI/?ref=app Refer this code in case of any doubts feel free to ask

+1

Import java.util.Scanner; class Learn{ public static void main(String []args){ Scanner scan = new Scanner(System.in); int[] a = new int[10]; for(int i =0; i<a.length; i++){ a[i] = scan.nextInt(); } int sum =0; for(i=0; i<a.length; i++){ sum += a[i]; } double ave = sum/a.length ; int count = 0; for(int i =0; i<a.length; i++){ if(a[i] > ave){ count++; } } System.out.println("The avarage = " + ave); System.out.println(count + " numbers are greater than avarage."); } }

0

0

how?

0

Sum of the observation/no. Of observations. This is the formula for calculating average. So accordingly try to solve it

0

i dont know💔

0

Thank you very much❤️❤️❤️❤️❤️❤️❤️❤️

0

My pleasure

0

Thank you very much🤍🤍🤍🤍🤍🤍🤍