Q2) 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 legitimate sentence. Sample Input#1: Please enter a one line question or statement. How are you? Sample Output#1: Yes Sample Input #2: Please enter a one line question or statement. Everything is ok! Sample Output#2: Wow Sample Input #3: Please enter a one line question or statement. Welcome to SE210 Sample Output#3: “You always say" "Welcome to SE210”

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 30PE
icon
Related questions
icon
Concept explainers
Question
Q2) 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 legitimate sentence. Sample Input#1: Please enter a one line question or statement. How are you? Sample Output#1: Yes Sample Input #2: Please enter a one line question or statement. Everything is ok! Sample Output#2: Wow Sample Input #3: Please enter a one line question or statement. Welcome to SE210 Sample Output#3: “You always say" "Welcome to SE210”
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning