Write a program that reads a one-line sentence as input and then displays the following response: If the sentence ends with a question mark (?) and the input contains an even number of characters, display the word Yes. If the sentence ends with a question mark and the input contains an odd number of characters, display the word No. If the sentence ends with an exclamation point (!), display the word Wow. In all other cases, display the words You always say followed by the input string enclosed in quotes. Your output should all be on one line. Be sure to note that in the last case, your output must include quotation marks around the echoed input string. In all other cases, there are no quotes in the output. Your program does not have to check the input to see that the user has entered a leg

This project requires a three-way selection statement and gives more practice with string methods. The case statement can be used since the control expression is a single character, and, in fact, that is what the solution in this manual uses. It may be instructive to show the code using if/else, instead, and compare them for readability. This project will be extended to use a loop in the next chapter.

ee the code in AskOrTellMeSelection.java.

Computer Science & Information Technology

You might also like to view...

To add a graphic element, a(n) ________ cap, which is a capital letter formatted in a font size larger than the body text, can be added to the beginning of a paragraph

Fill in the blank(s) with correct word

Computer Science & Information Technology

What symbol can be used to represent a group of consecutive 0s in an IPv6 address?

A) Semicolon B) Double semicolon C) Double colon D) Period

Computer Science & Information Technology