Write a program class named SquareDisplay that asks the user for a positive integer no greater than 15.

LANGUAGE: JAVA

CHALLENGE:

19. Squares.
Write a program class named SquareDisplay that asks the user for a positive integer no greater than 15.
The program should then display a square on the screen using the character ‘X’.
The number entered by the user will be the length of each side of the square.
For example, if the user enters 5, the program should display the following: XXXXX XXXXX XXXXX XXXXX XXXXX INPUT and PROMPTS.
The program prompts for an integer as follows: “Enter an integer in the range of 1-15: “.

OUTPUT.
The output should be a square of X characters as described above.
CLASS NAMES.
Your program class should be called SquareDisplay

SOLUTION:

#include <iostream>
using namespace std;
int main() {
    int number = 55;
    while(number>15) {
        cout << "enter number: ";
        cin >> number;
    }

    int i = 0;
    char xs[number];
    while(i<number) {
        xs[i] = 'x';
        i++;
    }

    int f = 0;
    i = 0;
    while(i<number) {
        while(f<number) {
            cout << xs[f];
            f++;
        }

        cout << "\n";
        i++;
        f = 0;
    }
}