import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter two words separated by spaces: ");
String word1 = keyboard.next();
String word2 = keyboard.next();
if (word1.compareToIgnoreCase(word2)==0) {
System.out.println("You have only entered one word: \"" + word1.toUpperCase() + "\"");
} else {
System.out.println(
"You have entered two words: \"" + word1.toLowerCase() + "\" and \"" + word2.toLowerCase() + "\"");
}
keyboard.close();
}
}
Comments
Leave a comment