Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Good morning, This is my code. I cannot find my mistake in any way. I tried to solve it by replacing a lot of things,

Good morning,

This is my code. I cannot find my mistake in any way. I tried to solve it by replacing a lot of things, however this is not working. I always have the "expected expression" error that shows up whenever I try to run the program. In this example, we are trying to build a house by using the user's inputs.

#include

using namespace std;

int main()

{

// Welcome message.

char name[10];

cout<<"To start, please enter your name: ";

cin>>name;

cout<<"Welcome "<

// User enters the dimensions of the house

int count=1;

int width=0,height;

cout<<"Enter the desired height of the house: ";

cin>>height;

cout<<"Enter the desired width of the house: ";

cin>>width;

/* This loop allow to apply the

specifications for the width*/

while (width<1 || width%2==0){

cout<<" You entered either less than 1 or an even number, try again! ";

cin >> width;

count++; // Counter: Allows to stop the program after three tries.

if (count>2) {

cout<<"You seem to have troubles using the program.Please try again letter.";

break;

}

}

// Building the roof.

for (int i=1;i<=width;i=i+2)

{

for (int j=1;j<=i;j++) // Allows to apply the limitations for Building the roof of the house.

{

cout<<"*";

}

cout<

}

//Building the Body of the house

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

{

cout << "|";

for (int j = 1; j <= 10; j++)

{

if (i == 0)

{

cout << "-";

}

else

{

cout << " ";

}

}

cout << "|" << endl;

}

//Repetition of the steps

char answer;

cout<<"Would you like to draw another house? (y/n) "<

cin>>answer;

if ((answer='y'))

{

{

int count=1;

int width=0,height;

cout<<"Enter the desired height of the house: ";

cin>>height;

cout<<"Enter the desired width of the house: ";

cin>>width;

{

{

while (width<1 || width%2==0){

cout<<" You entered either less than 1 or an even number, try again! ";

cin >> width;

count++;

if (count>2) {

cout<<"You seem to have troubles using the program.Please try again letter.";

break;

}

}

}

{

for (int i=1;i<=width;i=i+2)

{

for (int j=1;j<=i;j++) // Allows to apply the limitations for Building the roof of the house.

{

cout<<"*";

}

cout<

}

}

{ for (int i = 0; i <= height; i++)

{

cout << "|";

for (int j = 1; j <= 10; j++)

{

if (i == 0)

{

cout << "-";

}

else

{

cout << " ";

}

}

cout << "|" << endl;

}

}

else if (answer=='n')

{

break;

}

cout << "Thank you for using the program , goodbye" << 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_2

Step: 3

blur-text-image_3

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

From Herds To Insights Harnessing Data Analytics For Sustainable Livestock Farming

Authors: Prof Suresh Neethirajan

1st Edition

B0CFD6K6KK, 979-8857075487

More Books

Students also viewed these Databases questions

Question

Question Who can establish a Keogh retirement plan?

Answered: 1 week ago

Question

What is the role of the Joint Commission in health care?

Answered: 1 week ago