in Education by
Write a program to read name of 10 student from keyboard and arrange them alphabetically. Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
import java.util.Scanner; public class Alphabetical_Order { public static void main(String[] args) { int n; String temp; Scanner s = new Scanner(System.in); System.out.print(“Enter number of names you want to enter:”); n = s.nextInt(); String names[] = new String[n]; Scanner s1 = new Scanner(System.in); System.out.println(“Enter all the names:”); for(int i = 0; i < n; i++) { names[i] = s1.nextLine(); } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (names[i].compareTo(names[j])>0) { temp = names[i]; names[i] = names[j]; names[j] = temp; } } } System.out.print(“Names in Sorted Order:”); for (int i = 0; i < n – 1; i++) { System.out.print(names[i] + “,”); } System.out.print(names[n – 1]); } } hope it help u

Related questions

0 votes
    WRITE A PROGRAM TO READ DETAILS LIKE NAME, CLASS , AGE OF A STUDENT AND THEN PRINT THE DETAILS FIRSTLY IN ... THEN IN SEPERATE LINES Select the correct answer from above options...
asked Dec 30, 2021 in Education by JackTerrance
0 votes
    Write a program to store 10 names in an array. Arrange these in alphabetical orderby sorting. Print the sorted list. ... , LUCY, etc. Select the correct answer from above options...
asked Dec 12, 2021 in Education by JackTerrance
0 votes
    Write a JAVA program to store the marks of any 5 subjects in different variables. Calculate total and average. ... ANY INPUT METHOD Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    Write a JAVA program to store the marks of any 5 subjects in different variables. Calculate total and average. ... total and average. Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    Write a program to generate first 20 terms of Fibonacci series and store them in single dimension array. Display ... from the array Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    Write a Java program to read two strings from command line arguments and check the equality of two strings using string function. Select the correct answer from above options...
asked Dec 9, 2021 in Education by JackTerrance
0 votes
    Write a program in python to insert ten friends name in a list, then print 3rd, 5th and 9th value from the list (using data structure) Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    Write a program which sends the name of a text file from the client to server and display the message on the ... file present or not. Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    What is/are the name of device in which keyboard is referred as ‘keypad’? a) Laptop b) Notebook c) Tabs d) All of these Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    5. Write a program to read and store the following data in two different arrays. Using Binary Search Method search for ... 85, 72, 89 Select the correct answer from above options...
asked Dec 15, 2021 in Education by JackTerrance
0 votes
    write a C program to Read a number.Find sum of digit at even position in a number and multiplication of digit ... position in a number. Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    write a C program to Read a number . find sum of digit at even position in a number and multiplication of ... position in a number. Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    write a program to read an integer and find its reverse. note: if user enter 1234 then the output should be 4321 in Python Select the correct answer from above options...
asked Dec 2, 2021 in Education by JackTerrance
0 votes
    Write a program to prompt the user for days and rate per day to compute total pay. Use 50 days and a rate ... the string to a number. Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
...