### creating a cone for my rocket ship

Here is what I have come up with so far. The goal is to have a rocket ship with two triangles - one on the bottom and one on the top. I am finished with the assignment, but for extra credit I can choose to have my cones be generated to scale with the height & width of the ship itself. I would like to do that so that I can get the points, but mostly because I'm a little OCD.

Anyone care to throw some ideas at me?

Teacher says:

 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.

Now, below is my work. It does what it is supposed to do. It asks for the height, width, number of stages (number of rectangles to be drawn), and then if the height is even it draws a rectangle with space in the middle. If it is odd it draws the rectangle filled with asterisks. This is what was requested, as it is supposed to represent either an empty rocket (even) or an odd one.

I am going to get back to working on the cone now, but if anyone has some ideas, please let me know.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214`` `````` #include #include #include #include using namespace std; void rowRow1(int wide); void rowRow2(int hi, int blankBlank); void spaceJam(int blankBlank, int hi); void make(int width, int height, int stages); void get(int &width, int &height, int &stages); void cone (int &width); int main() { int width; int height; int stages; get(width, height, stages); //cone(width); make(width, height, stages); //cone(width); return 0; } /* 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 */ /* cout << " *" << endl; cout << " * * " << endl; cout << "* *" << endl; */ void cone(int &width) { if (width % 2 == 0) { cout << " **" << endl; } else if (width % 2 != 0) { cout << " *" << endl; } cout << " * * " << endl; cout << "* *" << endl; } void get(int &width, int &height, int &stages) { cout << "enter height " << endl; cin >> height; if (height < 3 || height > 15) { cout << "Please enter a new height" << endl; cin >> height; } cout << "enter width " << endl; cin >> width; if (width < 3 || width > 15) { cout << "Please enter a new wid" << endl; cin >> width; } cout << "enter stages " << endl; cin >> stages; } void make(int width, int height, int stages) { int tminus; for (tminus = 0; tminus < stages; tminus++) { rowRow1(height); rowRow2(width - 2, height - 2); rowRow1(height); } } void spaceJam(int hi) { int blankBlank; cout << "*"; for (blankBlank = 0; blankBlank < hi; blankBlank++) { if (hi % 2 == 0) { cout << " "; } else if (hi % 2 != 0) { cout << "*"; } } cout << "*" << endl; } void rowRow1(int height) { for (int r1 = 0; r1 < height; r1++) { cout << "*"; } cout << endl; } void rowRow2(int hi, int blankBlank) { for (int r2 = 0; r2 < hi; r2++) { spaceJam(blankBlank); } } ``````
Hi there,

Let's break down the assignment:

 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

I'm assuming by "good decomposition" the teacher means you should create (a) separate function(s) to perform this task. The assignment gives you pretty much what you need, you will only need to convert it into code. The only thing you need to keep in mind is that the spaces in between increase. In rough code:

 ``1234567891011121314151617`` ``````num_spaces=0; cone_rows = width/2; if (width%2 != 0) cone_rows+=1; for (size_t i=0; i

It's quite rough and doesn't address all the issues, but I'd rather not give you the exact solution per this forums homework policy. Hope this gets you underway, please do let us know if you have any further questions.

All the best,
NwN

Topic archived. No new replies allowed.