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

Identify three structural (not comments or formatting) improvements that could b

ID: 3743707 • Letter: I

Question

Identify three structural(not comments or formatting) improvements that could be made to the program. Explain why these are improvements. Implement the improvements in a fully documented and compilable c++ program

#include <iostream>

#include<string>

using namespace std;

const string BLACK = "********"; //define a line of black squares

const string WHITE = " ";//define a line of white squares

int main()

{

string whiteRow; //a row beginning with white squares

string blackRow; //a row beginning with black squares

//create a white-black row by concatenating the basic strings

whiteRow = WHITE + BLACK + WHITE + BLACK + WHITE + BLACK + WHITE + BLACK;

//create a black-white row by concatenating the basic strings

blackRow = BLACK + WHITE + BLACK + WHITE + BLACK + WHITE + BLACK + WHITE;

//print five white-black spaces

cout << whiteRow << endl;

cout << whiteRow << endl;

cout << whiteRow << endl;

cout << whiteRow << endl;

cout << whiteRow << endl;

//print five black-white rows

cout << blackRow << endl;

cout << blackRow << endl;

cout << blackRow << endl;

cout << blackRow << endl;

cout << blackRow << endl;

//print five white-black spaces

cout << whiteRow << endl;

cout << whiteRow << endl;

cout << whiteRow << endl;

cout << whiteRow << endl;

cout << whiteRow << endl;

//print five black-white rows

cout << blackRow << endl;

cout << blackRow << endl;

cout << blackRow << endl;

cout << blackRow << endl;

cout << blackRow << endl;

//print five white-black spaces

cout << whiteRow << endl;

cout << whiteRow << endl;

cout << whiteRow << endl;

cout << whiteRow << endl;

cout << whiteRow << endl;

//print five black-white rows

cout << blackRow << endl;

cout << blackRow << endl;

cout << blackRow << endl;

cout << blackRow << endl;

cout << blackRow << endl;

//print five white-black spaces

cout << whiteRow << endl;

cout << whiteRow << endl;

cout << whiteRow << endl;

cout << whiteRow << endl;

cout << whiteRow << endl;

//print five black-white rows

cout << blackRow << endl;

cout << blackRow << endl;

cout << blackRow << endl;

cout << blackRow << endl;

cout << blackRow << endl;

} return 0;

Explanation / Answer

#include #include using namespace std; const string BLACK = "********"; //define a line of black squares const string WHITE = " "; //define a line of white squares int main() { string whiteRow; //a row beginning with white squares string blackRow; //a row beginning with black squares //create a white-black row by concatenating the basic strings // 1. improvement 1 for(int i = 0; i < 4; ++i) { whiteRow += WHITE + BLACK; } // 2. improvement 2 //create a black-white row by concatenating the basic strings for(int i = 0; i < 4; ++i) { blackRow += BLACK + WHITE; } // 3. improvement 3 for(int i = 0; i < 4; ++i) { for(int j = 0; j < 5; ++j) { cout
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