Guest User

Untitled

a guest
Jul 14th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Alphabetize {
  4.     public static void main(String[] args) {
  5.         String word1, word2, word3;
  6.         Scanner keyboard = new Scanner(System.in);
  7.  
  8.         for(int i=1; i<4; i++){
  9.             System.out.println("Give me " + " word:");
  10.             switch(i) {
  11.                 case 1:
  12.                     word1 = keyboard.nextLine();
  13.                 case 2:
  14.                     word2 = keyboard.nextLine();
  15.                 case 3:
  16.                     word3 = keyboard.nextLine();
  17.             }
  18.         }
  19.  
  20.         if (word1.compareTo(word2)<0 && word2.compareTo(word3)<0) {
  21.             System.out.println("The words are in alphabetical order");
  22.         }
  23.         else {
  24.             System.out.println("The words arent' in alphabetical order");
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment