#include <iostream> using namespace::std; // Function prototypes void displayBox
ID: 3683216 • Letter: #
Question
#include <iostream>
using namespace::std;
// Function prototypes
void displayBox ( int length );
void displayBox ( int length, char fillChar );
void displayBox ( int width, int height );
void displayBox ( int width, int height, char FillChar );
//--------------------------------------------------------------------
int main()
{
int boxLength, // Input box dimensions
boxWidth,
boxHeight;
char boxFill; // Input fill character
// Test the displayBox(length) and displayBox(length,fillChar)
// functions.
cout << endl << "Enter the length of a side: ";
cin >> boxLength;
displayBox(boxLength);
cout << endl << "Enter the fill character: ";
cin >> boxFill;
displayBox(boxLength,boxFill);
// Test the displayBox(width,height) and
// displayBox(width,height,fillChar) functions.
cout << endl << "Enter the width and height of the box: ";
cin >> boxWidth >> boxHeight;
displayBox(boxWidth,boxHeight);
cout << endl << "Enter the fill character: ";
cin >> boxFill;
displayBox(boxWidth,boxHeight,boxFill);
return 0;
}
//--------------------------------------------------------------------
void displayBox ( int length )
{
// call the 2 agrument function, int and char
char fill = " ";
displayBox(length, fill);
}
void displayBox ( int length, char fillChar )
{
// call the 3 argument function3
displayBox(length, length, fillChar);
}
void displayBox ( int width, int height )
{
// call the 3 argument function
char fil = " ";
displayBox(width, height, fill);
}
void displayBox ( int width, int height, char FillChar )
{
// using nested loops, write this function
}
Explanation / Answer
I do not understand what you mean by implementing using nested loop so, I just displayed and observed the output in CodeBlocks IDE.
#include <iostream>
using namespace::std;
// Function prototypes
void displayBox ( int length );
void displayBox ( int length, char fillChar );
void displayBox ( int width, int height );
void displayBox ( int width, int height, char FillChar );
//--------------------------------------------------------------------
int main()
{
// Input box dimensions
int boxLength, boxWidth,boxHeight;
char boxFill; // Input fill character
// Test the displayBox(length) and displayBox(length,fillChar)
// functions.
cout << endl << "Enter the length of a side: ";
cin >> boxLength;
displayBox(boxLength);
cout << endl << "Enter the fill character: ";
cin >> boxFill;
displayBox(boxLength,boxFill);
// Test the displayBox(width,height) and
// displayBox(width,height,fillChar) functions.
cout << endl << "Enter the width and height of the box: ";
cin >> boxWidth >> boxHeight;
displayBox(boxWidth,boxHeight);
cout << endl << "Enter the fill character: ";
cin >> boxFill;
displayBox(boxWidth,boxHeight,boxFill);
return 0;
}
//--------------------------------------------------------------------
void displayBox ( int length )
{
// call the 2 argument function, int and char
char fill = ' ';
displayBox(length, fill);
}
void displayBox ( int length, char fillChar )
{
// call the 3 argument function3
displayBox(length, length, fillChar);
}
void displayBox ( int width, int height )
{
// call the 3 argument function
char fill = ' ';
displayBox(width, height, fill);
}
void displayBox ( int width, int height, char FillChar )
{
// using nested loops, write this function
cout << width << " ";
cout << height << " ";
cout << FillChar << " ";
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.