Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a project titled Lab5_Figures. This project shall contain multiple files. Write a program that repeatedly asks the user to select either square, left or

Create a project titled Lab5_Figures. This project shall contain multiple files. Write a program that repeatedly asks the user to select either square, left or right triangle, then inputs the figure size and then prints the appropriate shape in stars. For square, the program should ask whether the user wants a filled or a hollow square. The program should quit if the user inputs an invalid option. See an example dialog below:

1. square 2. top left triangle 3. top right triangle select figure: 1 select size: 4 filled or hollow [f/h]: h **** * * * * **** 1. square 2. top left triangle 3. top right triangle ... 

You can reuse your code from the Looping lab. Place star-printing code in four separate functions: filledSquare, hollowSquare, leftTriangle and rightTriangle. Each function should accept a single integer parameter - the size of the figure and return no value (be a void-function). Create three separate files figures.cpp, figures.h, and figuresInput.cpp. Place the triangle and square function definitions in figures.cpp and their prototypes in figures.h. Make sure that the header file is protected against multiple inclusion. Place the main function in figuresInput.cpp

The code which is supposed to be reused is:

#include

using std::cin; using std::cout; using std::endl;

int main(){

cout << "Input Number: ";

int n;

cin >> n;

for (int i = 0; i < n; i++)

{

for (int j = 0; j < n; j++)

cout << "*";

cout << endl;

}

cout << endl;

cout << endl;

for (int i = 0; i < n; i++)

{

for (int j = 0; j < i+1; j++)

cout << "*";

cout << endl;

}

cout << endl;

for (int i = 0; i < n; i++)

{

for (int j = 0; j < i ; j++)

cout << " ";

for (int j = 0; j < n-i; j++)

cout << "*";

cout << endl;

}

cout << endl;

cout << endl;

for (int i = 0; i < n; i++)

{

for (int j = 0; j < n; j++)

{

if (i == 0)

cout << "*";

else if (j == 0)

cout << "*";

else if (i == n)

cout << "*";

else if (j == n)

cout << "*";

else

cout << " ";

}

cout << endl;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

10. Are you a. a leader? b. a follower? _______

Answered: 1 week ago