This is the code so far #include // for cin and cout #include // for setw() and setfill() using namespace std; // so that we don't need to preface every cin and cout with std:: void printSpaces(int n, int end) { for (int j = n; j > end; j--) { cout << " "; } } void printFirstTwoBuildingSection(int n, int startSpacing) { int start = 2 * ((n / 2) - 1), end = 0; for (int i = 0; i < n; i++) { printSpaces(startSpacing, 0); cout << "|"; if (i < (n / 2)) { printSpaces(i, 0); cout << "\\"; printSpaces(start, 0); cout << "/"; start -= (2); printSpaces(i, 0); cout << "|" << endl; } else { printSpaces(n - i - 1, 0); cout << "/"; printSpaces(end, 0); cout << "\\"; end += (2); printSpaces(n - i - 1, 0); cout << "|" << endl; } } printSpaces(startSpacing, 0); cout << "/"; for (int i = 0; i < n; i++) { cout << "-"; } cout << "\\" << endl; } 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) { int sections; cout << "Number of building sections -> "; cin >> sections; int n = 1 - (sections - 2) + sections * 2; int sizeOfBuild = 2; cout << setw(n) << " /\\ " << endl; cout << setw(n) << " || " << endl; cout << setw(n) << " || " << endl; cout << setw(n) << " -- " << endl; cout << setw(n) << "|++|" << endl; cout << setw(n) << "====" << endl; for (int i = 1; i <= sections; i++, sizeOfBuild += 2) { printFirstTwoBuildingSection(sizeOfBuild, sections - i); } } cout << endl; return 0; }

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

This is the code so far

#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::


void printSpaces(int n, int end)
{
for (int j = n; j > end; j--)
{
cout << " ";
}
}
void printFirstTwoBuildingSection(int n, int startSpacing)
{
int start = 2 * ((n / 2) - 1), end = 0;
for (int i = 0; i < n; i++)
{
printSpaces(startSpacing, 0);
cout << "|";
if (i < (n / 2))
{
printSpaces(i, 0);
cout << "\\";
printSpaces(start, 0);
cout << "/";
start -= (2);
printSpaces(i, 0);
cout << "|" << endl;
}
else
{
printSpaces(n - i - 1, 0);
cout << "/";
printSpaces(end, 0);
cout << "\\";
end += (2);
printSpaces(n - i - 1, 0);
cout << "|" << endl;
}
}
printSpaces(startSpacing, 0);
cout << "/";
for (int i = 0; i < n; i++)
{
cout << "-";
}
cout << "\\" << endl;
}
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)
{
int sections;
cout << "Number of building sections -> ";
cin >> sections;
int n = 1 - (sections - 2) + sections * 2;
int sizeOfBuild = 2;
cout << setw(n) << " /\\ " << endl;
cout << setw(n) << " || " << endl;
cout << setw(n) << " || " << endl;
cout << setw(n) << " -- " << endl;
cout << setw(n) << "|++|" << endl;
cout << setw(n) << "====" << endl;
for (int i = 1; i <= sections; i++, sizeOfBuild += 2)
{
printFirstTwoBuildingSection(sizeOfBuild, sections - i);
}
}

cout << endl;
return 0;
}

### Instructions

**Problem Statement:**

Add the code to also display the tower base. The tower base width should be two characters wider on each edge than the bottom-most building section, with the sections above it centered above the base. Running your program again choosing 3 sections should now look like the following:

```
Choose from among the following options:
 1. Display original graphic
 2. Display building
 3. Exit the program
Your choice -> 2
Number of building sections -> 3

       /\
       ||
      ||  
     --
    |++|
    ===
   |\ /|
   |/ \|
  //--\\
  |\  /|
  | \/ |
 /|    |\
 |__X__|
     / \   
    /___\ 
++++++++++
```

**Explanation:**

- The user is prompted to choose from among three options: display the original graphic, display building, or exit the program.
- Upon choosing to display the building and specifying the number of building sections as 3, the program generates an ASCII representation of a tower.
- The tower consists of different building sections:
  - The top section of the tower is illustrated by a `/\` shape.
  - The subsequent sections have vertical lines `||` representing the middle part of sections.
  - The base of the tower, as shown in the final line of the text, is represented by the `++++++++++` string, making it wider than the topmost section by two characters on each edge.

This graphic demonstrates how the different sections of the tower are centered and aligned above the base.
Transcribed Image Text:### Instructions **Problem Statement:** Add the code to also display the tower base. The tower base width should be two characters wider on each edge than the bottom-most building section, with the sections above it centered above the base. Running your program again choosing 3 sections should now look like the following: ``` Choose from among the following options: 1. Display original graphic 2. Display building 3. Exit the program Your choice -> 2 Number of building sections -> 3 /\ || || -- |++| === |\ /| |/ \| //--\\ |\ /| | \/ | /| |\ |__X__| / \ /___\ ++++++++++ ``` **Explanation:** - The user is prompted to choose from among three options: display the original graphic, display building, or exit the program. - Upon choosing to display the building and specifying the number of building sections as 3, the program generates an ASCII representation of a tower. - The tower consists of different building sections: - The top section of the tower is illustrated by a `/\` shape. - The subsequent sections have vertical lines `||` representing the middle part of sections. - The base of the tower, as shown in the final line of the text, is represented by the `++++++++++` string, making it wider than the topmost section by two characters on each edge. This graphic demonstrates how the different sections of the tower are centered and aligned above the base.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
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