Help on an assignment for programming class!

Feb 19, 2013 at 3:23am
Hi! I'm new to this forum and am seeking some help on an assignment in my programming class. I've been at this for a while and can't figure out what to do.

Problem Statement:

The goal of this programming assignment is to use iteration (for loops or while loops) and condition statements (if statements or switch statements) to create a variety of patterns using ASCII characters. Functions must be used to help break up your code. In particular, your task is to prompt the user for a size, and then output the following five patterns:

Solid Square Pattern

* * * * *
* * * * *
* * * * *
* * * * *
* * * * *

Letter V Pattern

* *
* *
* *
* *
*
Big * Pattern

* * *
* * *
* * *
* * * * * * *
* * *
* * *
* * *
Checkerboard Pattern

* * *
* *
* * *
* *
* * *
Rectangle Outline Pattern

* * * * *
* *
* * * * *
Your program should work for any size in the range [5..20], and do error checking to be sure the size is in this range. For the rectangle outline pattern, you will need to input both length and width of the rectangle. For the other patterns, you can assume that length equals width. Since the size(s) of the pattern is an input parameter, it would be a very BAD idea to "hard code" the output of patterns using cout statements. Instead, you need to use iteration and conditions to create the output patterns.


That is the text of the assignment. Here's what I have so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
using namespace std;


void linebreak()
{
    cout <<"         ";
    cout << endl;
}

void square()
{
    for (int x = 0; x < 5; x++)

        {
        for (int i = 0; i < 5; i++)
            cout << "* ";
            cout << endl;
        } 
    
}



int main()
{
 
    square();    
    linebreak();
    return 0;
  
}


I've created the first block of asterisks, but I'm struggling to come up with how to use conditional statements to create the others. The V Pattern is the one giving me the most trouble. Any nudge in the right direction would be greatly appreciated. Thank you in advance!
Last edited on Feb 19, 2013 at 3:32am
Topic archived. No new replies allowed.