Please write a program that prints the woodchuck tongue twister when run with the given input sequence of strings. Please note that spaces (" ") must be present in the output, capital letters are not the same as lowercase, and it should end with "!".
Please write a program that prints the woodchuck tongue twister when run with the given input sequence of strings. Please note that spaces (" ") must be present in the output, capital letters are not the same as lowercase, and it should end with "!".
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 7PE
Related questions
Question
I need help at this question. Please provide accurately answer with details. Please solve this questions as formating shows in question.
![### Educational Programming Exercise: Constructing Strings Using Input Variables
#### Objective:
Write a program that outputs the woodchuck tongue twister when run with the specific input sequence of strings. Note that spaces (" ") must be included in the output, capital letters are distinct from lowercase, and the output should end with '!'.
#### Input:
The program receives a sequence of strings in the following order:
- "If a"
- "wood"
- "chuck"
- "could"
- "."
- "then"
- "the"
- "would"
- "!"
- "as"
- "much"
- "!"
#### Output:
The expected output is:
```
If a woodchuck could chuck wood then the woodchuck would chuck as much wood as the woodchuck would!
```
#### Constraints:
Ensure every line of your code is identical to one of the lines provided below. This constraint helps focus on concatenation using input variables.
#### Code Guidelines:
**Use these lines once in your program:**
```java
String message = input(); // Line to initialize the message
String wood = input(); // Line to store the string "wood"
String chuck = input(); // Line to store the string "chuck"
String could = input(); // Line to store the string "could"
String the = input(); // Line to store the string "the"
String as = input(); // Line to store the string "as"
String much = input(); // Line to store the string "much"
String a = input(); // Line to store the string "!"
print message; // Line to print the final message
```
**Use these lines repeatedly in your program:**
```java
message = message + wood + chuck; // Concatenate "wood" and "chuck"
message = message + input(); // Concatenate input to message
message = message + message; // Duplicate the message
message = message + wood; // Concatenate "wood"
message = message + as; // Concatenate "as"
message = message + much; // Concatenate "much"
message = message + could; // Concatenate "could"
message = message + chuck; // Concatenate "chuck"
```
**Example of Incorrect Code:**
Do not use any other lines of code in your program.
```java
String message = input(); // This initializes](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa471b51a-0850-4e57-a059-1b322d7c0961%2F22e55a55-05b7-4bdd-b508-ad91cb59d9cd%2Fgnnv8s9_processed.png&w=3840&q=75)
Transcribed Image Text:### Educational Programming Exercise: Constructing Strings Using Input Variables
#### Objective:
Write a program that outputs the woodchuck tongue twister when run with the specific input sequence of strings. Note that spaces (" ") must be included in the output, capital letters are distinct from lowercase, and the output should end with '!'.
#### Input:
The program receives a sequence of strings in the following order:
- "If a"
- "wood"
- "chuck"
- "could"
- "."
- "then"
- "the"
- "would"
- "!"
- "as"
- "much"
- "!"
#### Output:
The expected output is:
```
If a woodchuck could chuck wood then the woodchuck would chuck as much wood as the woodchuck would!
```
#### Constraints:
Ensure every line of your code is identical to one of the lines provided below. This constraint helps focus on concatenation using input variables.
#### Code Guidelines:
**Use these lines once in your program:**
```java
String message = input(); // Line to initialize the message
String wood = input(); // Line to store the string "wood"
String chuck = input(); // Line to store the string "chuck"
String could = input(); // Line to store the string "could"
String the = input(); // Line to store the string "the"
String as = input(); // Line to store the string "as"
String much = input(); // Line to store the string "much"
String a = input(); // Line to store the string "!"
print message; // Line to print the final message
```
**Use these lines repeatedly in your program:**
```java
message = message + wood + chuck; // Concatenate "wood" and "chuck"
message = message + input(); // Concatenate input to message
message = message + message; // Duplicate the message
message = message + wood; // Concatenate "wood"
message = message + as; // Concatenate "as"
message = message + much; // Concatenate "much"
message = message + could; // Concatenate "could"
message = message + chuck; // Concatenate "chuck"
```
**Example of Incorrect Code:**
Do not use any other lines of code in your program.
```java
String message = input(); // This initializes
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr