Write a program to accept 10 different numbers in a Single Dimensional Array (SDA). Arrange the numbers in ascending order by using 'Selection Sort' technique and display them. please give output
Answers
Answered by
3
Explanation:
import java.util.Scanner;
public class KboatSDANames
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
String names[] = new String[10];
System.out.println("Enter 10 names");
for (int i = 0; i < names.length; i++) {
names[i] = in.nextLine();
}
System.out.print("Enter a letter: ");
char ch = in.next().charAt(0);
ch = Character.toUpperCase(ch);
for (int i = 0; i < names.length; i++) {
if (Character.toUpperCase(names[i].charAt(0)) == ch) {
System.out.println(names[i]);
}
}
Similar questions