Need help with Program

I have been trying to write a program that makes a tile pattern like this:

  ____        ____
 /    \      /    \
/      \____/      \
\      /    \      /
 \____/      \____/
 /    \      /    \
/      \____/      \
\      /    \      /
 \____/      \____/





using the info the user enters. but i cant figure out how to fix my code. The result I get when I run the program keeps giving the wrong amount of tiles.


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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include <iostream>

using namespace std ;


/* Function Prototype */


void GetDim(int & tiles, int & courses);
/* From user, gets the desired number of tiles and courses. */
bool ValueCheck(int value);
/* Makes sure the user does not use zero or negative numbers. */
void Start(int courses);
/* Has a function with a loop to make the top of the tile. */
void MakeTiles(int tiles);
/* Has different fucntions within it.Each fuction has a loop
  for the way the tile is portyrayed. */
void Row1(int tiles);
/* The loop used here gives the first line after the top of the tile. */
void Row2(int tiles);
/* The loop used here gives the second line after the top of the tile.*/
void Row3(int tiles);
/* The loop used here gives the third line after the top of the tile. */
void Row4(int tiles);
/* The loop used here gives the fourth line after the top of the tile. */




int main ()
{
int tiles, courses, value,t ;

  GetDim(tiles, courses);
  if (ValueCheck(tiles))
      if (ValueCheck(courses))
          {
              t = courses;

              Start(tiles);
              while (t > 0)
                {
                    t--;
                    MakeTiles(tiles);
              }
          }

  cout << endl;

return 0;

}



/* function definition */
void GetDim(int & tiles, int & courses)

{

  cout << "How many tiles wide do you want the floor to be? ";
  cin >> tiles;
  cout << "How many courses do you want in your floor? ";
  cin >> courses;
}

bool ValueCheck(int value)
{
  if (value < 1)
  {
      cout << "You have entered a bad value" << endl;
      cout << endl;

  return false;

  }


  else if (value >= 1)

  return true;

  }

/* function definition */
void Start(int tiles)
{
  int t;

  t = 1;

  cout << "  ";

  while (t <= tiles)

  {
      if (t%2==1)
          cout << "____";
      else
          cout << "        ";

      t++;

  }

        cout << endl;
}

/* function definition */
void MakeTiles(int tiles)
{
  Row1(tiles);
  Row2(tiles);
  Row3(tiles);
  Row4(tiles);


}

/* function definition */
void Row1(int tiles)
{
  int t;
  cout << " /";
  for (int t = 1; t <= tiles; t++)

  {
        if (t%2==1)
          cout <<"    \\" ;
        else
          cout << "      /" ;

  }

  cout << endl;
}

/* function definition */
void Row2(int tiles)
{
  int t;
  cout << "/";
  for (int t = 1; t <= tiles; t++)

  {
      if (t%2==1)
          cout <<"      \\" ;
      else
          cout << "____/" ;

  }

  cout << endl;
  }

/* function definition */
void Row3(int tiles)
{
  int t;
  cout << "\\      /";
  for ( t <= 1; t < tiles; t++)

  {
      if (t%2==1)
          cout <<"    \\" ;
      else
          cout << "      /" ;

  }

  cout << endl;
}

/* function definition */
void Row4(int tiles)
{
  int t;
  cout << " \\____/";
  for (int t = 1; t < tiles; t++)

  {
      if (t%2==1)
          cout <<"      \\" ;
      else
          cout << "____/" ;

  }


Any help or advice would be greatly appreciated.
Hello there, I thought you're doing an interesting program so I edited you code. I am aware that it won't display the way you like it if the given width is even. I'll leave that for you to solve. Good luck, hope this helps..

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#include <iostream>

using namespace std ;


/* Function Prototype */


void GetDim(int & tiles, int & courses);
/* From user, gets the desired number of tiles and courses. */
bool ValueCheck(int value);
/* Makes sure the user does not use zero or negative numbers. */
void Start(int courses);
/* Has a function with a loop to make the top of the tile. */
void MakeTiles(int tiles);
/* Has different fucntions within it.Each fuction has a loop
  for the way the tile is portyrayed. */
void Row1(int tiles);
/* The loop used here gives the first line after the top of the tile. */
void Row2(int tiles);
/* The loop used here gives the second line after the top of the tile.*/
void Row3(int tiles);
/* The loop used here gives the third line after the top of the tile. */
void Row4(int tiles);
/* The loop used here gives the fourth line after the top of the tile. */




int main ()
{
int tiles, courses, value,t ;

  GetDim(tiles, courses);
  if (ValueCheck(tiles))
      if (ValueCheck(courses))
          {
              t = courses;

              Start(tiles);
              while (t > 0)
                {
                    t--;
                    MakeTiles(tiles);
              }
          }

  cout << endl;

return 0;

}



/* function definition */
void GetDim(int & tiles, int & courses)

{

  cout << "How many tiles wide do you want the floor to be? ";
  cin >> tiles;
  cout << "How many courses do you want in your floor? ";
  cin >> courses;
}

bool ValueCheck(int value)
{
  if (value < 1)
  {
      cout << "You have entered a bad value" << endl;
      cout << endl;

  return false;

  }


  else if (value >= 1)

  return true;

  }

/* function definition */
void Start(int tiles)
{
  int t;

  t = 1;

  cout << "  ";

  while (t <= tiles)

  {
      if (t%2==1)
          cout << "____";
      else
          cout << "        ";

      t++;

  }

        cout << endl;
}

/* function definition */
void MakeTiles(int tiles)
{
  Row1(tiles);
  Row2(tiles);
  Row3(tiles);
  Row4(tiles);


}

/* function definition */
void Row1(int tiles)
{
  int t;
  cout << " /";

  //if (tiles%2==0) tiles--; // edited

  for (int t = 1; t <= tiles; t++)

  {
        if (t%2==1)
          cout <<"    \\" ;
        else
          cout << "      /" ;

  }

  cout << endl;
}

/* function definition */
void Row2(int tiles)
{
  int t;
  cout << "/";
  for (int t = 1; t <= tiles; t++)

  {
      if (t%2==1)
          cout <<"      \\" ;
      else {
          cout << "____/" ;       // edited
      }
  }

  cout << endl;
  }

/* function definition */
void Row3(int tiles)
{
  int t;
  cout << "\\";
  for ( t = 1; t <=tiles; t++) // edited t = 1 not t <=1

  {
      if (t%2==1)
          cout <<"      /" ;
      else
          cout << "    \\" ;

  }

  cout << endl;
}

/* function definition */
void Row4(int tiles)
{
  int t;
  cout << " \\"; // edited
  for (int t = 1; t <= tiles; t++) // edited

  {
      if (t%2==1)
          cout <<"____/" ; // edited
      else
          cout << "      \\" ;// edited

  }
  cout << endl;
}



Topic archived. No new replies allowed.