ok guys I need your help. What i need to do is create a program that prints out a user specified pattern. the user specifies the size and which pattern.

the patterns should llok like this

Patter 1 Pattern 2 Pattern 3 Pattern 4
5\$\$\$\$ \$\$\$\$5 \$\$\$\$\$ \$\$\$\$\$
\$5\$\$\$ \$\$\$5\$ \$\$\$\$5 5\$\$\$\$
\$\$5\$\$ \$\$5\$\$ \$\$\$55 55\$\$\$
\$\$\$5\$ \$5\$\$\$ \$\$555 555\$\$
\$\$\$\$5 5\$\$\$\$ \$5555 5555\$

so as you can see if a user picks pattern 4 with size 5 they get 5 rows and 5 columns or if they picked size 2 it would be 2 rows 2 columns. I have the code for the first two patterns working but the next two i cant get. I know i could get number 4 if I got number 3 but im stuck this is what i have so far mind the mess.

``````#include <iostream>				     // Need for cout,cin
#include<iomanip>                   // need setf,fixed,showpoint,setprecision
#include <stdio.h>				    // Need for getchar

using namespace std;
int greet(int pattern);

int pick_size(int size);

int main()
{
int user_choice;
int pattern;
int user_size;
int size;
int i;
int j;
int s;
int n;
n = 0;

user_choice = 0;
user_size= 0;
pattern = greet(user_choice);

size = pick_size(user_size);

s = size;

// Loop for pattern 1

if ( pattern == 1)
{
for ( j = 1; j <= size; j++ )
{
{
cout << "\n";
n++;
}
for ( i = 1 ; i <= size  ; i++)
if (i == n )
cout << s ;

else if ( i != n )
{
cout << "\$" ;

}
}
}

// loop for pattern 2

if ( pattern == 2)
{
n = size+1;
for ( j = 1; j <= size; j++ )
{
{
cout << "\n";
n--;
}
for ( i = 1 ; i <= size  ; i++)
if (i == n )
cout << s ;

else if ( i != n)
{
cout << "\$" ;

}
}
}

// Loop for pattern 3

if ( pattern == 3)
{
n = size;
for ( j = 1; j <= size; j++ )
{
{
cout << "\n";
}
for ( i = 1 ; i <= size  ; i++)
if ( j == 1)
{
cout << "\$" ;

}
else if ( i == n  )
{
cout << size ;
n--;
}
else if (i!= n)

cout << "\$" ;

}
}

//cout << " pattern" << pattern << endl; //test to see if pattern was returned correctly

//cout << " size" << size << endl; //test to see if pattern was returned correctly

cout.setf (ios::showpoint );
cout.setf( ios::fixed);
cout << setprecision(2);

cout << " Press enter to continue" << endl;
cin.ignore();
char ch = getchar();

return 0;

}

/*********************************************
** Greet Function
**
** Description: Greets the user and asks them to select an option from the menu
**
**
**
**
**
**
*************************************************/

int greet(int pattern)
{
int option;
do
{
cout << " Hello please pick an option from the menu:  \n 1. Pattern one \n 2. Pattern two \n 3. Pattern three \n";
cout << " 4. Pattern four \n 5. Quit" << endl;
cin >> option;

if (option < 1 && option > 5)

cout << " Please enter the correct number from the menu " << endl;

else
{
switch(option)
{
case 1:

cout << " You have selected pattern: 1" << endl;
break;
case 2:

cout << " You have selected pattern: 2" << endl;
break;
case 3:

cout << " You have selected pattern: 3" << endl;
break;
case 4:

cout << "you have selected pattern: 4" << endl;
break;

case 5:
cout << " You have selected to quit" << endl;
break;
}
}
}
while (option < 1 && option > 6);

return option;
}

/*
/*********************************************
** Size Function
**
** Description: Asks the user to select an  size option from the menu
**
**
**
**
**
**
*************************************************/

int pick_size(int size)

{
int size_num;
cout << " Please select a size 2-9" << endl;
cin >> size_num;

do
{

if (size_num < 2 && size_num > 9)
cout << " Please enter the correct size from the menu " << endl;

else
{
switch(size_num)
{

case 2:
cout << " You have selected size: 2" << endl;
break;

case 3:
cout << " You have selected size: 3" << endl;
break;

case 4:
cout << "you have selected size: 4" << endl;
break;

case 5:
cout << "you have selected size: 5" << endl;
break;

case 6:
cout << "you have selected size: 6" << endl;
break;

case 7:
cout << "you have selected size: 7" << endl;
break;

case 8:
cout << "you have selected size: 8" << endl;
break;

case 9:
cout << "you have selected size: 9" << endl;
break;
}
}
}while (size_num < 2 && size_num > 9);

return size_num;
}``````

Pattern # 3 :

``````\$\$\$\$\$   // Print('\$', 5) && Print('5', 0)
\$\$\$\$5   // Print('\$', 4) && Print('5', 1)
\$\$\$55   // Print('\$', 3) && Print('5', 2)
\$\$555   // Print('\$', 2) && Print('5', 3)
\$5555   // Print('\$', 1) && Print('5', 4)``````

That one help me i dont think. It's need to be in a loop statement

updated code so its esier to understand and im getting a little further with it it prints kinda what i want but not exactly now i get

\$\$\$\$\$
\$\$\$\$5
\$\$\$55
\$5555
\$5555
so as you can see row 4 is messed up for soem reason

``````#include <iostream>				     // Need for cout,cin
#include<iomanip>                   // need setf,fixed,showpoint,setprecision
#include <stdio.h>				    // Need for getchar

using namespace std;
int greet(int pattern);

int pick_size(int size);

int main()
{
int user_choice;
int pattern;
int user_size;
int size;
int col;
int row;
int s;
int count;
count = 0;

user_choice = 0;
user_size= 0;
int num_lines;
pattern = greet(user_choice);

size = pick_size(user_size);

s = size;

// Loop for pattern 1

if ( pattern == 1)
{
for ( row = 1; row <= size; row++ )
{
{
cout << "\n";
count++;
}
for ( col = 1 ; col <= size  ; col++)
if (col == count )
cout << s ;

else if ( col != count )
{
cout << "\$" ;

}
}
}

// loop for pattern 2

if ( pattern == 2)
{
count = size+1;
for ( row = 1; row <= size; row++ )
{
{
cout << "\n";
count--;
}
for ( col = 1 ; col <= size  ; col++)
if (col == count )
cout << s ;

else if ( col != count)
{
cout << "\$" ;

}
}
}

// Loop for pattern 3

if ( pattern == 3)
{
count = size;
for ( row = 1; row <= size; row++ )
{
{
cout << "\n";

}
for ( col = 1 ; col <= size  ; col++)
if ( row == 1)
{
cout << "\$" ;

}
else if ( col >= count && col != 1  )
{cout << size ;
count--;
}
else if (col < size)
cout << "\$" ;
else
cout << "\$";

}
}

//cout << " pattern" << pattern << endl; //test to see if pattern was returned correctly

//cout << " size" << size << endl; //test to see if pattern was returned correctly

cout.setf (ios::showpoint );
cout.setf( ios::fixed);
cout << setprecision(2);

cout << " Press enter to continue" << endl;
cin.ignore();
char ch = getchar();

return 0;

}

/*********************************************
** Greet Function
**
** Description: Greets the user and asks them to select an option from the menu
**
**
**
**
**
**
*************************************************/

int greet(int pattern)
{
int option;
do
{
cout << " Hello please pick an option from the menu:  \n 1. Pattern one \n 2. Pattern two \n 3. Pattern three \n";
cout << " 4. Pattern four \n 5. Quit" << endl;
cin >> option;

if (option < 1 && option > 5)

cout << " Please enter the correct number from the menu " << endl;

else
{
switch(option)
{
case 1:

cout << " You have selected pattern: 1" << endl;
break;
case 2:

cout << " You have selected pattern: 2" << endl;
break;
case 3:

cout << " You have selected pattern: 3" << endl;
break;
case 4:

cout << "you have selected pattern: 4" << endl;
break;

case 5:
cout << " You have selected to quit" << endl;
break;
}
}
}
while (option < 1 && option > 6);

return option;
}

/*
/*********************************************
** Size Function
**
** Description: Asks the user to select an  size option from the menu
**
**
**
**
**
**
*************************************************/

int pick_size(int size)

{
int size_num;
cout << " Please select a size 2-9" << endl;
cin >> size_num;

do
{

if (size_num < 2 && size_num > 9)
cout << " Please enter the correct size from the menu " << endl;

else
{
switch(size_num)
{

case 2:
cout << " You have selected size: 2" << endl;
break;

case 3:
cout << " You have selected size: 3" << endl;
break;

case 4:
cout << "you have selected size: 4" << endl;
break;

case 5:
cout << "you have selected size: 5" << endl;
break;

case 6:
cout << "you have selected size: 6" << endl;
break;

case 7:
cout << "you have selected size: 7" << endl;
break;

case 8:
cout << "you have selected size: 8" << endl;
break;

case 9:
cout << "you have selected size: 9" << endl;
break;
}
}
}while (size_num < 2 && size_num > 9);

return size_num;
}``````