Computer Science, asked by pkhobragade640, 1 month ago

develop a Java program to accept 10 names from the user to store them in array of string and print them in Alphabetical order. ​

Answers

Answered by edwixrj6
0

Answer:

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