Help on a project

So my class has this project and I am just not sure where I should start. Here is the project. I would just like hints on where to start. Thanks Note: The __ in the sample are suppose to spaces

Complete the following programming project "Rocket"......which deals a great deal with "functional decomposition". This program is broken down into phases for your convenience only. Please turn in only your final product. Note: You are encouraged to use as much code from lesson#5 notes as you can for this project! DO NOT USE global variables.

Phase 1: Write a program that draws a rocket shape on the screen based on user input of three values, height, width and stages. The type of box generated (ie. an outline or filled-in) is based on a check for odd or even values input by the user for the box height (or number of rows). Here is the general specification given user input for the height of the box.....

Draw an outline of a box for each stage if the value for the height of the box (or number of rows) is an even number.
Draw a filled-in box for each stage if the value for the height of the box (or number of rows) is an odd number.

INPUT VALIDATION: Do not accept values less than 3 or greater than 15.

ROCKET SAMPLE#1 WITH 2 STAGES
ROCKET BODY HAS TWO EVEN HEIGHT BOX SHAPES
(i.e., each with height = 6 or number of rows = 6)
NOTE THAT THE BOX SHAPE HAS A CARGO BAY THAT IS EMPTY

__*
_*_*
*___*
***** < top row
*___*
*___* <= box outline for stage#1
*___*
*___*
***** < bottom row
***** < top row
*___*
*___* <= box outline for stage#2
*___*
*___*
***** < bottom row
__*
_*_*
*___*



ROCKET SAMPLE#2 WITH 2 STAGES
ROCKET BODY HAS TWO ODD HEIGHT BOX SHAPES
(i.e., each with height = 7 or number of rows = 7)
NOTE THAT THE BOX SHAPE HAS A CARGO BAY THAT IS FILLED

__*
_*_*
*___*
***** < top row
*****
*****
***** <= box filled for stage#1
*****
*****
***** <bottom row
***** < top row
*****
*****
***** <= box filled for stage#2
*****
*****
***** < bottom row
__*
_*_*
*___*


Your main function in phase 1 may look like either of these:
function decomposition #1 - seperate functions to generate an outline or filled in box shape functional decomposition#2 - one drawBox function but with procedures within the functions to generate both an outline and a filled in box shape

int main()
{

//functions for sample#1
drawCone();
drawEvenBox();
drawEvenBox();
drawCone();

//functions for sample#2
drawCone();
drawOddBox();
drawOddBox();
drawCone();
}



int main()
{

//functions for sample#1 and sample#2
drawCone();
drawBox(); //procedures within the function to generate both box shapes
drawCone();


}


The functions in this phase do not necessarily need external data. You may use simple cout statements (no loops are necessary) in your drawCone function, but you must write your drawBox function or the drawEvenBox and drawOddBox functions using loops. For example, you can set-up a drawBox function with a procedure within it that uses nested loops to generate a 5 x 6 or a 5 x 7 box shape as shown in the sample figures above. You may not use the setw() function in this project!

Phase 2: In this phase inside int main() you will allow the user to specify three things and validate input to make sure that the values are not less than 3 or greater than 15. If needed, allow the user to re-input values that meet the program specification.:

1. The height of each stage
2. The width of each stage
3. How many stages in the rocket

[A "stage" in your rocket is one box] Your program will look a lot like it did before except that you will add 3 cout/cin statements including a data validation routine before you call the functions. In addition, you will now have some arguments in your function calls, and some other changes to call the appropriate functions (HINT: based on the height of each stage) to generate the correct type of rocket shape.

Notice that in addition to generating two possible rocket types (based on stage height) if you run the program and choose a different width for your stages, the cone won't really fit correctly anymore. I won't make you fix this, but you can fix it for 10 points of extra credit if you like. However, I will not help you with the extra credit. In order to get the extra credit, the number of rows of your cone must be equal to the width of the stages divided by 2 (plus 1 for odd widths). If the stage width is an even number, your cone must have two stars in the top row instead of one. If you do this perfectly and use good decomposition in the process you'll get 10 extra credit points.

Phase 3: In this phase you won't change what the program produces. We're just going to improve on the organization a bit. Change your program so that the main function looks like this:


int main()
{
<declarations>

getDimensions(<parameters>);
drawRocket(<parameters>);
}



Please make sure to place a comment near each of your function definitions, use good decomposition, separate your functions with at least 1 inches of whitespace and DO NOT use global variables. I suggest that now would be a good time to reread the program style, formatting and documentation section in the syllabus and review Dale text Appendix F reference section on functions.

Paste your source code from phase 3 followed by your output from phase 3. A single output is sufficient, unless you do the extra credit, in which case you should show examples of both even and odd cone widths.
It seems like the professor laid it out for you:


Your main function in phase 1 may look like either of these:
function decomposition #1 - seperate functions to generate an outline or filled in box shape functional decomposition#2 - one drawBox function but with procedures within the functions to generate both an outline and a filled in box shape

int main()
{

//functions for sample#1
drawCone();
drawEvenBox();
drawEvenBox();
drawCone();

//functions for sample#2
drawCone();
drawOddBox();
drawOddBox();
drawCone();
}



int main()
{

//functions for sample#1 and sample#2
drawCone();
drawBox(); //procedures within the function to generate both box shapes
drawCone();


}
so here is where I get confused I think.



int main()
{

//functions for sample#1 and sample#2
drawCone();
drawBox(); //procedures within the function to generate both box shapes
drawCone();


}


don't I need two drawBoxes? one for filled and one without?
Ok so I got a pretty good start on my code but on line 72 I get the following error
"error: lvalue required as left operand of assignment" and I am not sure as to why. Here is my code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <cstdlib>

using namespace std;

//functions for sample#1
void drawOddCone(int width)
{
    for(int j=1;j<=width;j+=2)
    {
        for(int i=1;i<=(width-j)/2;i++)
        {
        cout<<" ";
        }
        cout<<"*";
            if(j>1)
            {
                for(int h=1; h<=j-2; h++)
                {
                cout <<" ";
                }
                cout<<"*";
            }
            cout<<endl;
    }
}
void drawOddBoxFilled(int height,int width)
{
    for(int k= 1; k <=height;k++)
    {
        for(int m=1;m<=width;m++)
        {
        cout<<"*";
        }
        cout<<endl;
    }
}
void drawOddBoxOpen(int height,int width)
{

}


//functions for sample#2
void drawConeEven(int width)
{

}
void drawEvenBoxFilled(int height, int width)
{

}
void drawEvenBoxOpen(int height, int width)
{

}

int main()
{
    int rocketHeight = 0,rocketWidth = 0,rocketStage = 0;
    char rocketType;

cout <<"Please enter a number for the height of the rocket?\n";
cin>>rocketHeight;
cout <<"Please enter a number for the width of the rocket?\n";
cin>>rocketWidth;
cout <<"Please enter a number for the stages of the rocket?\n";
cin>>rocketStage;
cout<<"Would you like the rocket to be filled or open?(F/O)\n";
cin>>rocketType;
// displays rocket with odd height and odd width.
if((rocketHeight %2 != 0) && (rocketWidth %2 != 0) && (rocketType = 'F'|| rocketType = 'f'))
{
drawOddCone(rocketWidth);
for (int l =1;l<=rocketStage; l++)
{
drawOddBoxFilled(rocketHeight,rocketWidth);
}
drawOddCone(rocketWidth);
}
}
Line 72: == is the comparison operator. = is the asignment operator.
Your code should be:
 
(rocketType == 'F'|| rocketType == 'f')
of course duh thanks I willpost if I have further problem s otherwise ill mark this as solved.
Okay, so I finished my code and it works I was hoping someone could look it over and check to see if I missed anything. I think I got everything to work so just let me know.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#include <iostream>
#include <cstdlib>

using namespace std;

//functions for sample#1
void drawOddCone(int width)
{
    for(int j=1;j<=width;j+=2)
    {
        for(int i=1;i<=(width-j)/2;i++)
        {
        cout<<" ";
        }
        cout<<"*";
            if(j>1)
            {
                for(int h=1; h<=j-2; h++)
                {
                cout <<" ";
                }
                cout<<"*";
            }
            cout<<endl;
    }
}
void drawOddBoxFilled(int height,int width)
{
    for(int k= 1; k <=height;k++)
    {
        for(int m=1;m<=width;m++)
        {
        cout<<"*";
        }
        cout<<endl;
    }
}
void drawOddBoxOpen(int height,int width)
{
    for (int i = 0; i < height; i++)
    {
        for (int j = 0; j < width; j++)
        {
            if ((j == 0) || (j == width - 1))
            {
            cout << "*";
            }
                else if ((i == 0) || (i == height - 1))
                {
                cout << "*";
                }
                    else
                    {
                    cout << " ";
                    }
        }
        cout << endl;
    }
    }

//functions for sample#2
void drawConeEven(int width)
{
 for(int j=1;j<=width/2;j++)
    {
        for(int i=1;i<=(width/2)-j;i++)
        {
        cout<<" ";
        }
        cout<<"*";
            if(j>=1)
            {
                for(int h=1; h<=2*j-2; h++)
                {
                cout <<" ";
                }
                cout<<"*";
            }
            cout<<endl;
    }
}
void drawEvenBoxFilled(int height, int width)
{
  for(int k= 1; k <=height;k++)
    {
        for(int m=1;m<=width;m++)
        {
        cout<<"*";
        }
        cout<<endl;
    }
}
void drawEvenBoxOpen(int height, int width)
{
    for (int i = 0; i < height; i++)
    {
        for (int j = 0; j < width; j++)
        {
            if ((j == 0) || (j == width - 1))
            {
            cout << "*";
            }
                else if ((i == 0) || (i == height - 1))
                {
                cout << "*";
                }
                    else
                    {
                    cout << " ";
                    }
        }
        cout << endl;
    }
}

void getDiminsions(int &h, int &w , int &s, char &t)
{
    cout <<"Please enter a number for the height of the rocket?\n";
    cin>>h;

    cout <<"Please enter a number for the width of the rocket?\n";
    cin>>w;

    cout <<"Please enter a number for the stages of the rocket?\n";
    cin>>s;

    cout<<"Would you like the rocket to be filled or open?(F/O)\n";
    cin>>t;
}

int main()
{
    char again;
    int rocketHeight;
    int rocketWidth;
    int rocketStage;
    char rocketType;

do
{

    getDiminsions(rocketHeight,rocketWidth,rocketStage,rocketType);


    if((rocketHeight>3 && rocketHeight<15) && (rocketWidth>3 && rocketWidth<15))
    {

        // displays rocket with odd height and odd width and filled.
        if((rocketHeight %2 != 0) && (rocketWidth %2 != 0) && (rocketType == 'F'|| rocketType == 'f'))
        {
                drawOddCone(rocketWidth);
                for (int l =1;l<=rocketStage; l++)
                {
                drawOddBoxFilled(rocketHeight,rocketWidth);
                }
                drawOddCone(rocketWidth);
        }

        // displays rocket with odd height and odd width and open.
        if((rocketHeight %2 != 0) && (rocketWidth %2 != 0) && (rocketType == 'O'|| rocketType == 'o'))
        {
            drawOddCone(rocketWidth);
            for (int l =1;l<=rocketStage; l++)
            {
            drawOddBoxOpen(rocketHeight,rocketWidth);
            }
            drawOddCone(rocketWidth);
        }

        //displays rocket with even height and even width and filled.
        if((rocketHeight %2 == 0) && (rocketWidth %2 == 0) && (rocketType == 'F'|| rocketType == 'f'))
        {
            drawConeEven(rocketWidth);
            for (int q =1;q<=rocketStage;q++)
            {
            drawEvenBoxFilled(rocketHeight,rocketWidth);
            }
            drawConeEven(rocketWidth);
}

        //displays rocket with even height and even width and open.
        if((rocketHeight %2 == 0) && (rocketWidth %2 == 0) && (rocketType == 'O'|| rocketType == 'o'))
        {
            drawConeEven(rocketWidth);
            for (int q =1;q<=rocketStage;q++)
            {
            drawEvenBoxOpen(rocketHeight,rocketWidth);
            }
            drawConeEven(rocketWidth);
        }

        // displays rocket with even height and odd width and filled.
        if((rocketHeight %2 == 0) && (rocketWidth %2 != 0) && (rocketType == 'F'|| rocketType == 'f'))
        {
            drawOddCone(rocketWidth);
            for (int l =1;l<=rocketStage; l++)
            {
            drawEvenBoxFilled(rocketHeight,rocketWidth);
            }
            drawOddCone(rocketWidth);
        }

        // displays rocket with even height and odd width and open.
        if((rocketHeight %2 == 0) && (rocketWidth %2 != 0) && (rocketType == 'O'|| rocketType == 'o'))
        {
            drawOddCone(rocketWidth);
            for (int l =1;l<=rocketStage; l++)
            {
            drawEvenBoxFilled(rocketHeight,rocketWidth);
            }
            drawOddCone(rocketWidth);
        }

        // displays rocket with odd height and odd width and filled.
        if((rocketHeight %2 != 0) && (rocketWidth %2 == 0) && (rocketType == 'F'|| rocketType == 'f'))
        {
            drawConeEven(rocketWidth);
            for (int l =1;l<=rocketStage; l++)
            {
            drawOddBoxFilled(rocketHeight,rocketWidth);
            }
            drawConeEven(rocketWidth);
        }

        // displays rocket with odd height and odd width and open.
        if((rocketHeight %2 != 0) && (rocketWidth %2 == 0) && (rocketType == 'O'|| rocketType == 'o'))
        {
            drawConeEven(rocketWidth);
            for (int l =1;l<=rocketStage; l++)
            {
            drawOddBoxFilled(rocketHeight,rocketWidth);
            }
            drawConeEven(rocketWidth);
        }
    }

    else
    {
    cout <<"Invalid Input. Please try again or quit.\n";
}

cout<<"Would you like to do this again?(y/n)"<<endl;
cin>>again;

}while(again == 'Y' || again =='y');

return 0;

}
Topic archived. No new replies allowed.