*4.24(对三个城市排序)编写一个程序,提示用户输入三个城市名称,然后以升序进行显示。
下面是一个运行示例:
Enter the first city:
Enter the second city:
Enter the third city:
The three cities in alphabetical order are Atlanta Chicago Los Angeles
*4.24(Sort three cities) Write a program that prompts the user to enter three cities and displays them in alphabetical order.
Here is a sample run:
Enter the first city:
Enter the second city:
Enter the third city:
The three cities in alphabetical order are Atlanta Chicago Los Angeles
下面是参考答案代码:
import java.util.*;
public class SortThreeCitiesQuestion24 {
public static void main(String[] args) {
String city1,city2,city3;
Scanner inputScanner = new Scanner(System.in);
System.out.print("Enter the first city: "