Back to Challenge Set 11

Code Challenge: Star Rectangle

Difficulty  

divider

The Brief

What they asked for
I'm making a birthday banner and I want a simple block of
stars I can print out. Tell me how wide and how tall, and
give me a solid rectangle — no gaps, no pattern, just
stars.

Write your requirements list before you write any code. Input, calculate, output, and anything you had to decide for yourself.


Notes

  • Two numbers in, and neither one changes what a square is made of — every square in this brief is a star. That is the whole difference between this and Checkerboard in this same set.
  • A loop inside a loop: the outer one counts rows, the inner one counts columns.
  • Print the star with Console.Write, not Console.WriteLine, or every star lands on its own line instead of building a row.
  • Something still has to move to the next line after each row finishes — that line goes outside the inner loop and inside the outer one.

Where to Start

Only one-star challenges have this section. If you already know how to begin, skip it — and when you move up to two stars, working out the order yourself is part of the job.

  1. Read rows and columns, both as int.
  2. Write an outer for loop that counts the rows.
  3. Inside it, write an inner for loop that counts the columns and prints one star each pass with Console.Write.
  4. After the inner loop ends, but still inside the outer one, print a blank Console.WriteLine() to move to the next row.

Sample Output

Sample Output
Rows? 3
Columns? 5
*****
*****
*****

Verified in a real run — 3 rows of 5 columns each, no gaps, no pattern.


Submit

Your requirements list and your program file, named cc-star-rectangle.

Commence Challenge