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
تركي الشهري9 Answers
New Answerhttps://code.sololearn.com/cqSifWp47kKI/?ref=app Refer this code in case of any doubts feel free to ask
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."); } }
Sum of the observation/no. Of observations. This is the formula for calculating average. So accordingly try to solve it
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message