Question #283449

Write a program to store 25 numbers in a single dimension array. Then display sum of first 10 numbers of the array and display how many numbers are present more than the sum in rest of the array values.


Expert's answer



import java.util.Scanner;


public class App {


	/**
	 * The start point of the program
	 * 
	 * @param args
	 * 
	 */
	public static void main(String[] args) {
		Scanner keyBoard = new Scanner(System.in);
		double numbers[] = new double[25];


		for (int i = 0; i < 25; i++) {
			System.out.print("Enter number " + (i + 1) + ": ");
			numbers[i] = keyBoard.nextDouble();
		}
		double sum = 0;
		for (int i = 0; i < 10; i++) {
			sum += numbers[i];
		}
		
		int counter=0;
		for (int i = 10; i < 25; i++) {
			if(sum < numbers[i]) {
				counter++;
			}
		}
		System.out.println("The sum of first 10 numbers of the array: " + sum);
		System.out.println(counter+" numbers are present more than the sum in rest of the array values");


		keyBoard.close();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS