Write a program that solves this problem using selection structures and concatenation. Input #1: Any String. Input #2: "size 1" or Any other String. Input #3: "pet 1", or "pet 2". pr "pet 3", pr Any other String. Output: 1 string built and printed according to following Algorithm: Declare a string variable called message and initialize it as the empty string "". If Input #1 is "definite article", then add the string "The "to the message. - If Input #1 is "indefinite article", then add the string "A" to the message. (Don't do anything if Input #1 is neither "definite article", nor "indefinite article.".) If Input #2 is "size 1", then add the string "big "to the message. Otherwise, add the string "small" to the message. If Input #3 is "pet If Input #3 is "pet 1", then add the string "cat." to the message and print message. 2", then add the string "dog." to the message and print message. If Input #3 is "pet 3", then add the string "rat." to the message and print message. If Input #3 is any other value, don't print message and instead print "ERROR". Examples IN: "definite article", "size 1", "pet 1" OUT: "The big cat." IN: "indefinite article", "size 2", "pet 2" OUT: "A small dog." IN: "Antecedent", "size 3", "pet 3" OUT: "small rat." IN: "definite article", "size 1", "Alligator" OUT: "ERROR" IN: "definite article", "big", "pet 1" OUT: "The small cat." IN: "indefinite article", "big", "pet 1" OUT: "A small cat." IN: OUT: "small dog." "", "pet 2"

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

I need acurate answer with explanation so, please solve it carefully. 

II!
Assignment 3b - Logic
n
6
of 8
X PDF Assignment 3, Strings and Logic. X +
Ⓒ File | C:/Users/jamil/Downloads/Assignment%203,%20Strings%20and%20Logic.pdf
Q
+
(0)
CD Page view A Read aloud |
Add textDraw
Write a program that solves this problem using selection structures and concatenation.
Input #1: Any String.
Input #2: "size 1" or Any other String.
Input #3: "pet 1", or "pet 2". pr "pet 3", pr Any other String.
Output: 1 string built and printed according to following Algorithm:
Declare a string variable called message and initialize it as the empty string ""
If Input #1 is "definite article", then add the string "The "to the message.
If Input #1 is "indefinite article", then add the string "A" to the message.
(Don't do anything if Input #1 is neither "definite article", nor "indefinite article.".)
If Input #2 is "size 1", then add the string "big "to the message.
Otherwise, add the string "small "to the message.
If Input #3 is "pet
If Input #3
1", then add the string "cat." to the message and print message
2", then add the string "dog." to the message and print message.
"pet
If Input #3 is "pet 3", then add the string "rat." to the message and print message.
If Input #3 is any other value, don't print message and instead print "ERROR".
Examples
IN: "definite article", "size 1", "pet 1"
OUT: "The big cat."
IN: "indefinite article", "size 2", "pet 2"
OUT: "A small dog."
IN: "Antecedent", "size 3", "pet 3"
OUT: "small rat."
IN: "definite article", "size 1", "Alligator"
OUT: "ERROR"
IN: "definite article", "big", "pet 1"
OUT: "The small cat."
IN: "indefinite article", "big", "pet 1"
OUT: "A small cat."
V
IN: **.**.
"", "pet 2"
OUT: "small dog."
Highlight
Erase
Q
8
7
503
x
Transcribed Image Text:II! Assignment 3b - Logic n 6 of 8 X PDF Assignment 3, Strings and Logic. X + Ⓒ File | C:/Users/jamil/Downloads/Assignment%203,%20Strings%20and%20Logic.pdf Q + (0) CD Page view A Read aloud | Add textDraw Write a program that solves this problem using selection structures and concatenation. Input #1: Any String. Input #2: "size 1" or Any other String. Input #3: "pet 1", or "pet 2". pr "pet 3", pr Any other String. Output: 1 string built and printed according to following Algorithm: Declare a string variable called message and initialize it as the empty string "" If Input #1 is "definite article", then add the string "The "to the message. If Input #1 is "indefinite article", then add the string "A" to the message. (Don't do anything if Input #1 is neither "definite article", nor "indefinite article.".) If Input #2 is "size 1", then add the string "big "to the message. Otherwise, add the string "small "to the message. If Input #3 is "pet If Input #3 1", then add the string "cat." to the message and print message 2", then add the string "dog." to the message and print message. "pet If Input #3 is "pet 3", then add the string "rat." to the message and print message. If Input #3 is any other value, don't print message and instead print "ERROR". Examples IN: "definite article", "size 1", "pet 1" OUT: "The big cat." IN: "indefinite article", "size 2", "pet 2" OUT: "A small dog." IN: "Antecedent", "size 3", "pet 3" OUT: "small rat." IN: "definite article", "size 1", "Alligator" OUT: "ERROR" IN: "definite article", "big", "pet 1" OUT: "The small cat." IN: "indefinite article", "big", "pet 1" OUT: "A small cat." V IN: **.**. "", "pet 2" OUT: "small dog." Highlight Erase Q 8 7 503 x
Expert Solution
steps

Step by step

Solved in 4 steps with 8 images

Blurred answer
Knowledge Booster
Random Class and its operations
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT