2. Add the code to display the first two building sections below the top of the tower, all still left-justified. Your output should now look like the following: Choose from among the following options: 1. Exit the program 2. Display building Your choice -> 2 || |++ |--\ |\ /| | \ | |7 \| |----\

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

C++

This is what i have so far. Can you use a for loop for the code.

#include <iostream> // for cin and cout
#include <iomanip> // for setw() and setfill()
using namespace std; // so that we don't need to preface every cin and cout with std::

int main()
{
int menuOption = 0;

cout << "Choose from among the following options:\n"
<< "1. Exit the program\n"
<< "2. Display building\n"
<< "Your choice -> ";
cin >> menuOption;
cout << endl; // Leave a blank line after getting the user input for the menu option.

// See if exit was chosen
if (menuOption == 1) {
exit(0);
}

// Menu 2

if (menuOption == 2)
{
cout << " /\\ " << endl;
cout << " || " << endl;
cout << " || " << endl;
cout << " -- " << endl;
cout << "|++|" << endl;
cout << "====" << endl;
}

cout << endl;
return 0;
}

**Step 2: Adding Code to Display Building Sections**

In this step, you are asked to add code that will display the first two building sections below the top of the tower, with all sections left-justified.

### Instructions:
Here is the instruction and sample output for your reference:

1. Add the code to display the first two building sections below the top of the tower, all still left-justified.

2. Your output should now look like the following:

```
Choose from among the following options:
1. Exit the program
2. Display building
Your choice -> 2

 /\
|  |
|  |
 --
|++|
 ===
|\ /|
|/ \|
|   |
|\ /|
|/ \|
/----\
```

### Output Explanation:

Upon choosing option "2", the output displays the top part of a tower structure, represented using ASCII characters. The structure of the tower in the output is explained as follows:

- The top of the tower starts with a triangular tip (using "/\\" characters).
- Below the tip, there are vertical lines ("|  |") making up the body of the tower.
- A pair of horizontal lines (" --") separates the top from the middle section.
- The middle section includes a small box with "++" symbols and "===" lines below it.
- This is followed by several layers of ASCII art that represents different sections of the building below the initial top section.
- The sections are composed of slash-and-backslash patterns (e.g., "|\\ /|", "|/ \\|"), vertical lines, and horizontal lines.

This code likely involves basic ASCII art to visually represent the tower structure. Coding such an output helps in learning various aspects of programming such as loops, conditionals, and string manipulation.
Transcribed Image Text:**Step 2: Adding Code to Display Building Sections** In this step, you are asked to add code that will display the first two building sections below the top of the tower, with all sections left-justified. ### Instructions: Here is the instruction and sample output for your reference: 1. Add the code to display the first two building sections below the top of the tower, all still left-justified. 2. Your output should now look like the following: ``` Choose from among the following options: 1. Exit the program 2. Display building Your choice -> 2 /\ | | | | -- |++| === |\ /| |/ \| | | |\ /| |/ \| /----\ ``` ### Output Explanation: Upon choosing option "2", the output displays the top part of a tower structure, represented using ASCII characters. The structure of the tower in the output is explained as follows: - The top of the tower starts with a triangular tip (using "/\\" characters). - Below the tip, there are vertical lines ("| |") making up the body of the tower. - A pair of horizontal lines (" --") separates the top from the middle section. - The middle section includes a small box with "++" symbols and "===" lines below it. - This is followed by several layers of ASCII art that represents different sections of the building below the initial top section. - The sections are composed of slash-and-backslash patterns (e.g., "|\\ /|", "|/ \\|"), vertical lines, and horizontal lines. This code likely involves basic ASCII art to visually represent the tower structure. Coding such an output helps in learning various aspects of programming such as loops, conditionals, and string manipulation.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Types of Loop
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education