Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have code in C++ I need someone's help in fixing it: Here is the code #include #include using namespace std; // function to print

I have code in C++ I need someone's help in fixing it: Here is the code

#include #include using namespace std;

// function to print the menu void printMenu() { cout<<"Program 1: Gladiolus"<

// function to print given number of white spaces void printSpaceForward(int count) { for(int i = 1; i <= count; i++) cout<<":"; }

// function to display gladiolus flower with given number of sections void displayGladiolus(int sections) { // level of sections for(int i = 1; i <= sections; i++) {

printSpaceForward(sections); cout<<"---"<

// print the upper part of a level, upto the '@' character level for(int j = 1; j <= i; j++) { printSpaceForward(sections-i); printSpaceForward(i-j);

cout<<"("; printSpaceForward(j); if(i==j) cout<<"@"; else cout<<" ";

printSpaceForward(j); cout<<")"<

// print the lower part of a level for(int j = i-1; j >= 1; j--) { printSpaceForward(sections-i); printSpaceForward(i-j);

cout<<"("; printSpaceForward(j); if(i==j) cout<<"@"; else cout<<" ";

printSpaceForward(j); cout<<")"<

} printSpaceForward(sections); cout<<"---"<

// print the stem part for(int i = 1; i <= sections; i++) { // for even count, print \| if(i%2 == 0) { printSpaceForward(sections); cout<<"\\|"<

// function to print the graphics void printGraphics() { cout<<"-----------------------------------------------"<

// main method int main() {

int choice, sections;

printMenu(); // print the menu // accept user's choice cout<<"Your choice -> "<>choice;

// compare user's choice and call appropriate methods switch(choice) { case 1: printGraphics(); break; case 2: cout<<"Number of sections -> "; cin>>sections; if(sections > 0) displayGladiolus(sections); break; case 3: exit(0); default: cout<<" Invalid choice!"; } cout<<" Exiting"<

return 0; }

Here is the output with 3 sections-

:::--- ::(:@:) :::--- ::(: :) :(::@::) ::(: :) :::--- ::(: :) :(:: ::) (:::@:::) :(:: ::) ::(: :) :::--- ::::|/ ::::| :::\| ::::| ::::|/ ::::|

What I need here is the colons to be only in the curly brackets and not outside of the curly brackets, and also the brackets without the @ symbol should have colons in there and as you can see they don't so in the middle if someone can help me with this. It should look like this:

---

{:@:}

---

{:::}

{::@::}

{:::}

---

{:::}

{:::::}

{:::@:::}

{:::::}

{:::}

---

|/ | \| | |/ |

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

3. What is a Duchenne smile?

Answered: 1 week ago

Question

Define Management or What is Management?

Answered: 1 week ago

Question

What do you understand by MBO?

Answered: 1 week ago

Question

Develop clear policy statements.

Answered: 1 week ago

Question

Draft a business plan.

Answered: 1 week ago

Question

Describe the guidelines for appropriate use of the direct plan.

Answered: 1 week ago