Fence Post Problems
- Write a void function simpleFence that, given the number of
fence posts, prints a fence as shown below. Test your program by allowing
the user to enter the number of fence posts to print repeatedly until 0 is
entered.
how many posts: 4
|---|---|---|
|---|---|---|
how many posts: 7
|---|---|---|---|---|---|
|---|---|---|---|---|---|
Write a void function fence that draws a fence with fence posts as
shown below. The
number of fence posts and the length of each cross-piece are parameters. For
example, fence(3,5) should draw the fence on the left and fence(5,3)
draws the fence on the right. Test your program by writing a separate function
that creates fences of 1, 2, 3, and 10 posts all with length three
cross-pieces. Then create fences with 5 posts that have cross-piece lengths of
0, 1, 2, 5, and 10.
|-----|-----| |---|---|---|---|
|-----|-----| |---|---|---|---|

Comments?