Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Classcode 9- struct houseInfo { int noBedRoom; int noBathRoom; int noGarage; int yearBuilt; double housePrice; string style; }; void readIN(houseInfo x[], int size); void print(houseInfo

Classcode 9- struct houseInfo
{
int noBedRoom;
int noBathRoom;
int noGarage;
int yearBuilt;
double housePrice;
string style;
};
void readIN(houseInfo x[], int size);
void print(houseInfo x[], int size);
int main()
{
houseInfo house[3];
readIN(house, 3);
print(house, 3);
system("pause");
return 0;
}
void readIN(houseInfo x[], int size)
{
for(int i = 0; i < size; i++)
{
cout<<"Enter in the no of Bathrooms for house "<
cin>>x[i].noBathRoom;
cout<<"Enter in the no of Bedrooms for house "<
cin>>x[i].noBedRoom;
cout<<"Enter in the no of Garages for house "<
cin>>x[i].noGarage;
cout<<"Enter in the year the house "<
cin>>x[i].yearBuilt;
cout<<"Enter in the price of house "<
cin>>x[i].housePrice;
cout<<"Enter in the style of house "<
cin>>x[i].style;
}
}
void print(houseInfo x[], int size)
{
for(int i = 0; i < size; i++)
{
cout<<"House "<
cout<
<
}
}
2. Using the structure given in classcode9, write a C++ program that adds the following functions. Also increase the maximum number of houses to 20.
a) Rewrite the readin function to read in the house details from a file. (Have a minimum of 10 houses and maximum of 15 houses). Style could be switched between apartment, townhouse, bungalow, mansion, duplex.
b) A function that takes in a year as an integer input and the list of houses, and outputs all the styles built after that year
c) A function that takes in a year and the house list and returns true if a house was built that year and false otherwise
d) A function that takes in a year as an integer input and the list of houses, and outputs the the name of the most frequent house style built before that year.
e) A function that takes in two houses and returns true if the are of the same size. Two houses are of the same size if the have the same no of bathrooms, bedrooms and garages
f) A function that takes in the house list and a house style and returns the average price of houses of that style.
g) A function that takes in a house and adds it to the house list
h) A function that takes in the house list and returns the number of houses with the similar sizes (Hint a nested loop will be needed)

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions