Advertisement
therrontelford

Alphabetize 2 cities

Nov 14th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. // USE THIS AS A GUIDE FOR NO. 24
  2.  
  3. import java.util.*;
  4. public class AlphabetizeTwoCities {
  5.  
  6.     public static void main(String[] args) {
  7. // alphabetize two cities
  8.         Scanner input=new Scanner(System.in);
  9.         System.out.println("Enter 2 cities followed by enter each time");
  10.         String city1=input.nextLine();
  11.         String city2=input.nextLine();
  12.        
  13.         if (city1.compareTo(city2) < 0)
  14.         {
  15.             System.out.println(city1 + "\n"+city2);
  16.         }
  17.         else
  18.         {
  19.             System.out.println(city2 + "\n"+city1);
  20.         }
  21.        
  22.     }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement