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.
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();
}
}
Comments
Leave a comment