[Solved]Create Class Based Monthly Budget Structure Last Week Include Member Items Rent Water Garb Q37202368
Create a class based on the monthly budget structure from lastweek but only include member items: rent, water and garbage.Include an accessor and a mutator (getter and setter) for eachitem, setup a default constructor (with some default values) andinclude a total function that is not stored as a member item butjust is calculated when requested.
Once you are done, create three objects as part of your programthat demonstrate your class including one that uses the defaultconstructor.
Monthly budget code:
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct Budget
{
int rent; // monthly rent
double gas; // Gas Utility bill
double water; // Water Utility bill
int garbage; // Barbage collection
string donation; // Donated money org for themonth
double total; // Monthly total of rent + gas + water +garbage
};
// Function prototypes
void getbudget(Budget&);
void budgetdisplay(Budget);
int main()
{
// Budget for four months
int Months = 4;
Budget plan[Months];
// Obtain and display budget for four months fromuser
for (int i = 0; i < Months; i++)
{
cout << endl << “Enterthe budget items for month ” << i + 1 << “:” <<endl;
getbudget(plan[i]);
budgetdisplay(plan[i]);
}
// Display average for Rent, Gas, Water, Garbageand Total
// First Create the total for eachcategory
double totrent = 0, totgarbage = 0;
double totgas = 0, totwater = 0, totalall = 0;
for (int i = 0; i < Months; i++)
{
totrent += plan[i].rent;
totgas += plan[i].gas;
totwater += plan[i].water;
totgarbage +=plan[i].garbage;
totalall += plan[i].total;
}
// Display the Average for each category
cout << endl;
cout << “Average Rent $”<< totrent / Months << endl;
cout << “Average Gas $”<< totgas / Months << endl;
cout << “Average Water $” <<totwater / Months << endl;
cout << “Average Garbage $” << totgarbage/ Months << endl;
cout << “Overall Average $” << totalall /Months << endl;
return 0;
}
void getbudget(Budget &mn)
{
cout << ” Apt. Rent: $”;
cin >> mn.rent;
cout << ” Gas bill: $”;
cin >> mn.gas;
cout << ” Water Bill: $”;
cin >> mn.water;
cout << ” Garbage Bill: $”;
cin >> mn.garbage;
cout << ” Name of group donated money is goingto: “;
cin >> mn.donation;
mn.total = mn.rent + mn.gas + mn.water +mn.garbage;
cout << “Overall Total for the month: $”<< mn.total << endl << endl;
}
void budgetdisplay(Budget mn)
{
cout << “Monthly budget:” << endl;
cout << setprecision(2) << fixed;
cout << ” Apt. Rent: $” << mn.rent<< endl;
cout << ” Gas bill: $” << mn.gas <<endl;
cout << ” Water Bill: $” << mn.water<< endl;
cout << ” Garbage Bill: $” << mn.garbage<< endl;
cout << ” Donated money to: ” <<mn.donation << endl;
cout << ” Overall Total: $” << mn.total<< endl << endl;
}
Expert Answer
Answer to Create a class based on the monthly budget structure from last week but only include member items: rent, water and garba… . . .
OR

