Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started