Can someone help with this C question Use this struct defini
Can someone help with this C++ question: (Use this struct definition for exercise this exercise)
Consider the following definition of the struct houseType: struct houseType { string style; int numOfBedrooms; int numOfBathrooms; int numOfCarsGarage; int yearBuilt; int finishedSquareFootage; double price; double tax; };
1. Using this definition, write C++ statements to do the following:
a) Declare variables oldHouse and newHouse of type houseType.
B) Store the following information into oldHouse: Style—Two-story, number of bedrooms—5, number of bathrooms—3, number of cars garage—4, year built—1975, finished square footage—3500, price— 675000, and tax—12500.
c) Copy the values of the components of oldHouse into the corresponding components of newHouse .
Solution
#include <iostream>
 #include <string>
 using namespace std;
//struct definition of housetype
 struct houseType
 {
     string style;
     int numOfBedrooms;
     int numOfBathrooms;
     int numOfCarsGarage;
     int yearBuilt;
     int finishedSquareFootage;
     double price;
     double tax;
};
//functin to display struct content
 void display(houseType ht)
 {
     cout<<\"Style: \"<<ht.style;
     cout<<\"\ Number of Bedrooms: \"<<ht.numOfBedrooms;
     cout<<\"\ Number of Bathrooms: \"<<ht.numOfBathrooms;
     cout<<\"\ Number of Cars garage: \"<<ht.numOfCarsGarage;
     cout<<\"\ Year Build: \"<<ht.yearBuilt;
     cout<<\"\ Finished Square Footage: \"<<ht.finishedSquareFootage;
     cout<<\"\ Price: \"<<ht.price;
     cout<<\"\ Tax: \"<<ht.tax;
 }
//main function
 int main()
 {
     //declare two housetype variables
    houseType oldHouse;
    houseType newHouse;
 
    //initialiaze oldhouse data
    oldHouse.style=\"Two story\";
    oldHouse.numOfBedrooms=5;
    oldHouse.numOfBathrooms=3;
    oldHouse.numOfCarsGarage=4;
    oldHouse.yearBuilt=1975;
    oldHouse.finishedSquareFootage=3500;
    oldHouse.price=675000;
    oldHouse.tax=12500;
 
    //display old house
    cout<<\"\ *****Content of Old House****\"<<endl;
    display(oldHouse);
 
    //copy oldhouse content to newhouse
    newHouse=oldHouse;
    cout<<\"\ \ ******Content of New House********\"<<endl;
    display(newHouse);
    return 0;
 }


