Answer:
import java.util.Scanner;
public class SortStrings3 {
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
String str1, str2, str3;
System.out.print("Enter the first city: ");
str1 = scanner.nextLine();
System.out.print("Enter the second city: ");
str2 = scanner.nextLine();
System.out.print("Enter the third city: ");
str3 = scanner.nextLine();
System.out.print("The three cities in alphabetical order are ");
if(str1.compareTo(str2) < 0 && str1.compareTo(str3) < 0){
System.out.print(str1+" ");
if(str2.compareTo(str3) < 0){
System.out.print(str2+" ");
System.out.println(str3);
}
else {
System.out.print(str3+" ");
System.out.println(str2);
}
}
else if(str2.compareTo(str1) < 0 && str2.compareTo(str3) < 0){
System.out.print(str2+" ");
if(str1.compareTo(str3) < 0){
System.out.print(str1+" ");
System.out.println(str3);
}
else {
System.out.print(str3+" ");
System.out.println(str1);
}
}
else{
System.out.print(str3+" ");
if(str1.compareTo(str2) < 0){
System.out.print(str1+" ");
System.out.println(str2);
}
else {
System.out.print(str2+" ");
System.out.println(str1);
}
}
}
}
EXPLANATION:
The task requires creating a program that will prompt users to input three cities named Atlanta, Chicago, and Los Angeles (which are to be sorted in ascending alphabetical order).
Thus, we're going to develop the code using a programming language called JAVA (JUST ANOTHER VIRTUAL ACCELERATOR).
We chose Java for this task because it is capable of loading, validating, and executing code on either single or multiple servers.
The code can be found in the attached document/file. Please take a look at it.