In my computer science class, our professor gave us an assignment of writing a program that would print out a pyramid made of starts. In order to do my assignment computer science concepts of loops inside of loops had to be used. Upon my first attempt of trying to write the program, I was met with a few compiler errors. I changed the program until I got it to correctly compile, but then another problem came up. Once the program was executed, it would print out an endless number of stars and wouldn’t stop until the program was halted.

I changed the program again and got it to print out starts and stop, but I didn’t get a pyramid. Instead, I got rows of starts that looked more like a rectangle. I was frustrated that another attempt didn’t result in the pyramid. I spent the next few hours making more changes, but the results were either the same, or resulted in some unnecessary compiler errors happening. I looked online for some help and came across a website that helps students complete their computer science homework. Using the website, I figured out why the program wasn’t printing out the stars correctly.

In order for the stars to make the pyramid shape, I needed to have one loop count down and increment two integers, and then the outer loop to do the same. This caused the program to print out one star on the first line, two starts on the second line, and so on. Once I had the basic pyramid shape printing, I edited the code to accept a numbered input. The original code only printed a pyramid that went up to five rows, but with the input option, any number can be used and the pyramid will have that many rows.