SHARE
TWEET

Untitled

a guest Dec 11th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class stringsort {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         System.out.println("Input First string: ");
  8.         Scanner input_1 = new Scanner(System.in);
  9.         String output_1 = input_1.next();
  10.        
  11.         System.out.println("\nInput next string: ");
  12.         Scanner input_2 = new Scanner(System.in);
  13.         String output_2 = input_2.next();
  14.  
  15.         int value = output_2.compareTo(output_1);
  16.        
  17.         if( value>0) {
  18.             System.out.println("\nString in Alphabetical order: ");
  19.             System.out.print(output_1+", ");
  20.             System.out.println(output_2);
  21.         }
  22.        
  23.         else if( value<0) {
  24.             System.out.println("\nString in Alphabetical order: ");
  25.             System.out.print(output_2+", ");
  26.             System.out.println(output_1);
  27.             }
  28.         else System.out.println("Strings in order");   
  29.  
  30.     }
  31.  
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top