Advertisement
Shavit

P. 9 Ex. 9.4

Dec 24th, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class FirstString {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         Scanner in = new Scanner (System.in);
  12.        
  13.         String s1, s2;
  14.         int compareResult;
  15.        
  16.         System.out.print("Enter your first string: ");
  17.         s1 = in.nextLine();
  18.        
  19.         System.out.print("Enter your second string: ");
  20.         s2 = in.nextLine();
  21.        
  22.         compareResult = s1.compareTo(s2);
  23.        
  24.         if(compareResult <= 0)
  25.             System.out.printf("%s\n%s", s1, s2);
  26.         else
  27.             System.out.printf("%s\n%s", s2, s1);
  28.        
  29.         in.close();
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement