1import java.util.Scanner;
2
3public class ProgrammingEx4_24 {
4
5 public static void main(String[] args) {
6 Scanner input = new Scanner(System.in);
7 System.out.print("Enter the first city:");
8 String first = input.nextLine();
9 System.out.print("Enter the second city:");
10 String second = input.nextLine();
11 System.out.print("Enter the third city:");
12 String third = input.nextLine();
13 String temp = "";
14
15 if (first.compareTo(second) > 0) {
16 temp = second;
17 second = first;
18 first = temp;
19
20 }
21 if (second.compareTo(third) > 0) {
22 temp = third;
23 third = second;
24 second = temp;
25
26 }
27 if (first.compareTo(second) > 0) {
28 temp = second;
29 second = first;
30 first = temp;
31
32 }
33 System.out.println("The three cities in alphabetical order are "
34 + first + " " + second + " " + third);
35 }
36
37}
38