Question
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
// 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 -> "< // 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started