Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2 (50 Marks) You are asked to write a C++ program which draws a house with a roof based on the following specifications. Application

Problem 2 (50 Marks) You are asked to write a C++ program which draws a house with a roof based on the following specifications. Application name: Display a welcome banner Step 1: Welcome user: Ask the user for their name and using their name welcome them to your application. Step 2: Request house dimensions and validate input: Ask the user to enter the width and height of the house to be drawn (Note: Both height and width are integer). The width must be odd and bigger than 1. If the user enters even numbers or a number less than 1 for the width, you are required to prompt the user until they enter an odd number. They have 3 tries for entering width. If after 3 tries they are still entering even numbers terminate your program with an appropriate personalized message otherwise move on to step 3. Step 3: Draw the house 3.1. Draw the roof: The roof consists of a set of stars on each row. Number of stars in the last row of the roof is equal to the width of the house. The first row starts with one * and you increase the number of starts in the next row bye 2 and repeat this process until you reach to the width. For example if the width is 5 the roof shape will be a triangle like this (1,3 and 5 stars): * * * * * * * * * Hint: The number of rows needed to print/draw the roof is half the width of the house+1. 3.2. Draw the body of the house: The body of the house has height+1 rows in all. Last row are drawn using the dash character (-). There are width dashes. The walls are represented by height rows. Each of the rows are made up of 2 characters of | in the left and right sides and the rest are spaces. 3.3. Keep track of the number of houses you have drawn. Step 4. Ask the user if they wish you to draw another house. If yes repeat steps 3. If no, move on to step 5. Step 5. End program: display this message: Hope you like your house(s)

please answer using functions and loops only.

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

More Books

Students also viewed these Databases questions

Question

The relevance of the information to the interpreter

Answered: 1 week ago

Question

You have

Answered: 1 week ago