Ok so for a project in my comp sci class we have to make a banner using a field of stars. We must enable the user to enter the number of rows(at least 1 but no more than 5) and columns(at least 5 but no more than 50), as well as the number of fields(at least 3, but no more than 10). Each field must be separated by 3 complete blank lines.
The program must include two functions: one to get the input data from the user, and one to draw each field. Use for loops to construct the fields, as well as to print out the muliple fields. We also can't use a string of'*'. Rather, we must print out individual stars.
My problems are that I don't know how to ask the user to input fields, as well as how to put that into the code. Also the program as it is right now, is not running after the input stage. The reason I have three for loops is because I thought that fields could be entered using a third for loop. Thanks for any future help!
Here is my code so far:
#include <iostream>
using namespace std;
void getVals(int numRows, int numColumns, int numFields);
void displayBanner(int numRows, int numColumns, int numFields);
void checkRows(int numRows);
void checkColumns(int numColumns);
void checkFields(int numFields);
const char c = '*';
int main(void)
{
int numRows=0, numColumns=0, numFields=0;
getVals(numRows, numColumns, numFields);
displayBanner(numRows, numColumns, numFields);
return 0;
}
void getVals(int numRows, int numColumns, int numFields)
{
cout << "Please enter the number of rows(1-5): ";
cin >> numRows;
checkRows(numRows);
cout << "Please enter the number of columns(5-50): ";
cin >> numColumns;
checkColumns(numColumns);
cout << "Please enter the number of fields(3-10): ";
cin >> numFields;
checkFields(numFields);
}
void displayBanner(int numRows, int numColumns, int numFields)
{
for(int i=1; i<=numRows; i++) {
for(int j=1; j<=numColumns; j++) {
for(int k=1; k<=numFields; k++) {
cout << c;
cout << endl;
}
}
cout << endl << endl;
}
}
void checkRows(int numRows)
{
while ((numRows < 1) || (numRows > 5)) {
cout << "Invalid value entered!\n";
cout << "Please re-enter your value, it must be from 1-5 inclusive: ";
cin >> numRows;
}
}
void checkColumns(int numColumns)
{
while ((numColumns < 5) || (numColumns > 50)) {
cout << "Invalid value entered!\n";
cout << "Please re-enter your value, it must be from 5-50 inclusive: ";
cin >> numColumns;
}
}
void checkFields(int numFields)
{
while ((numFields < 3) || (numFields > 10)) {
cout << "Invalid value entered!\n";
cout << "Please re-enter your value, it must be from 3-10 inclusive: ";
cin >> numFields;
}
}