Answer to Question #243325 in Java | JSP | JSF for gunna_b

Question #243325

Create a program that takes in two words, check for equality ignoring the cases, if the words are equal the print the word in upper case with an appropriate message however if the words are different then print the two words in lower case with an appropriate message


1
Expert's answer
2021-09-27T18:11:51-0400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter two words separated by spaces: ");
        String one = in.next();
        String two = in.next();
        if (one.equalsIgnoreCase(two)) {
            System.out.printf("You have only entered one word: \"%s\"\n", one.toUpperCase());
        } else {
            System.out.printf("You have entered two words: \"%s\" and \"%s\"\n", one.toLowerCase(), two.toLowerCase());
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

gunna_b
28.09.21, 08:50

Thank you very muvh our experts...You guys are the best

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS