Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Alphabetize {
- public static void main(String[] args) {
- String word1, word2, word3;
- Scanner keyboard = new Scanner(System.in);
- for(int i=1; i<4; i++){
- System.out.println("Give me " + " word:");
- switch(i) {
- case 1:
- word1 = keyboard.nextLine();
- case 2:
- word2 = keyboard.nextLine();
- case 3:
- word3 = keyboard.nextLine();
- }
- }
- if (word1.compareTo(word2)<0 && word2.compareTo(word3)<0) {
- System.out.println("The words are in alphabetical order");
- }
- else {
- System.out.println("The words arent' in alphabetical order");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment