Instructions

Your task assignment is to write a program that will "draw" a square and a triangle, comprised of a specified character. The best way to illustrate this is with sample output:

What character do you want to use shapes? #

How many rows/columns does your square have? 5

#####
#####
#####
#####
#####

How many rows does your triangle have? 5

#
##
###
####
#####

Here it is upside-down:

#####
####
###
##
#

The user will specify which character will be used to draw the shapes. The character can be anything (e.g., #, *, 4, A, x, etc).

The user will then specify how many rows/columns the square will be. In the example above, the user specified 5 as his/her chosen value, so each row of the square is 5 characters long, and there are 5 rows.

The triangle is a little different in that the first row starts with one character, and each row grows by 1 character in length until the last (nth) row is n characters long.

After "drawing" that triangle, your program should draw it again, only upside-down (the first row is n characters long and decreases by one character per row until the last (nth) row).

The shapes must be "drawn" using loops ( are probably best).

You can assume that valid, positive integers will be inputed number of rows shape. You are free to check input, but it won't be necessary.




 

 

    • 10 years ago
    A+ Work
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      qdrawsquareq.zip