Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that takes two lists of 5 positive integers each, and place them

ID: 3693776 • Letter: W

Question

Write a program that takes two lists of 5 positive integers each, and place them in two arrays called "rowList" and "columnList". Afterwards, generate 5 rectangles of asterisks, each with dimensions taken from the previous two arrays provided. The 1st elements of "rowList" and "columnList" would generate the first rectangle, the 2nd elements of "rowList" and "columnList" would generate the second rectangle, and so on. The input values for "rowList" and "columnList" should only be between 2 and 7. The program must implement and use a function called "printRectangle", which takes two input parameters (one for row numbers, and one for column numbers), and generates a rectangle with the dimension specified by the parameters (row and column).

Explanation / Answer

******* Try this program*********

#include<iostream>

usingnamespacestd;

voidprintRectangle(int width, int height) {

       int rows = 0;

       int cols = 0;

       while (rows < height) {

              cols = 0;

              while (cols < width) {

                     cols = (cols + 1);

                     cout<<"*";

              }

              rows = (rows + 1);

              cout<<endl;

       }

}

int main() {

       introwList[5];

       intcolumnList[5];

       intcurrentBox = 0;

       inttotalBoxes = 5;

       cout<<"Enter 5 positive integers for rowList (2 to 7)"<<endl;

       while (currentBox<totalBoxes) {

              cout<<currentBox<<": ";

              cin>>rowList[currentBox];

              while ((rowList[currentBox] < 2) || (rowList[currentBox] > 7)) {

                     cout<<" Rejected!"<<endl;

                     cout<<currentBox<<": ";

                     cin>>rowList[currentBox];

              }

              currentBox = (currentBox + 1);

       }

       cout<<endl;

       currentBox = 0;

       cout<<"Enter 5 positive integers for columnList (2 to 7)"<<endl;

       while (currentBox<totalBoxes) {

              cout<<currentBox<<": ";

              cin>>columnList[currentBox];

              while ((columnList[currentBox] < 2) || (columnList[currentBox] > 7)) {

                     cout<<" Rejected!"<<endl;

                     cout<<currentBox<<": ";

                     cin>>columnList[currentBox];

              }

              currentBox = (currentBox + 1);

       }

       cout<<endl;

       currentBox = 0;

       while (currentBox<totalBoxes) {

              cout<<rowList[currentBox] <<" rows "<<columnList[currentBox] <<" columns"<<endl;

              printRectangle(columnList[currentBox], rowList[currentBox]);

              cout<<endl<<endl;

              currentBox = (currentBox + 1);

       }

       return 0;

}

Hope this will help to you!

Thank You!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote