Can somebody please code this for me?

Write a program:
1. Ask the user for two positive integers between 2 and 10. (Input Validation: If the user enters other
numbers , you should display error message and ask the user to enter again.)
2. Use these two integers for the length and width of a rectangle. (If the numbers are different, the
larger of the two numbers should be used for the length and the smaller for the width.
3. Display a rectangle on the screen using the character ‘X’.
4. Ask the user whether he want to draw another rectangle. If yes, do 1-3 again. Otherwise, stop the
program
Input: two integers (between 2 and 10)
user’s choice(Y or N)
Here is something to start with.
#include <iostream>
#include <string>
using namespace std;

string drawSquare(int side);

int main()
{
int side;

cout << "Enter the side length of your square: ";
cin >> side;

cout << drawSquare(side) << endl;

return 0;
}

string drawSquare(int side)
{
for (int i = 0; i < side; i++)
{
for (int j = 0; j < side; j++)
{
cout << "x ";
}

cout << endl;
}

cout << endl;

return "done";
}
For the 2-10 part you would put.

while the side length is less than 2 or greater than 10, cout a error message and copy the original prompt.
Topic archived. No new replies allowed.