Question #285994

Write a program to store 15 numbers in an array. Then display all two digits number in ascending order using sorting and also display how many such numbers found.


Expert's answer



import java.util.Arrays;
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);
		int numbers[] = new int[15];
		for (int i = 0; i < 15; i++) {
			System.out.print("Enter the number " + (i + 1) + ": ");
			numbers[i] = keyBoard.nextInt();
		}
		Arrays.sort(numbers);
		int counter = 0;
		System.out.println("\nAll two digits number in ascending order");
		for (int i = 0; i < 15; i++) {
			if (numbers[i] >= 10 && numbers[i] < 100) {
				System.out.print(numbers[i] + " ");
				counter++;
			}
		}
		System.out.println("\nThe number of two digits values: " + counter);
		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