Answer:
See explaination fot program code
Step-by-step explanation:
Below is the program code
#include <iostream>
#include <iomanip>
using namespace std;
struct MonthlyBudget {
int house;
int util;
int he;
int trans;
int food;
int med;
int ins;
int ent;
int cloth;
int misc;
int gross;
};
void getSpentBudget(MonthlyBudget &spent)
{
cout << "Enter amount for housing: ";
cin >> spent.house;
cout << "Enter amount for utilities: ";
cin >> spent.util;
cout << "Enter amount for household expenses: ";
cin >> spent.he;
cout << "Enter amount for transportation: ";
cin >> spent.trans;
cout << "Enter amount for food: ";
cin >> spent.food;
cout << "Enter amount for medical: ";
cin >> spent.med;
cout << "Enter amount for insurance: ";
cin >> spent.ins;
cout << "Enter amount for entertainment: ";
cin >> spent.ent;
cout << "Enter amount for clothing: ";
cin >> spent.cloth;
cout << "Enter amount for miscellaneous: ";
cin >> spent.misc;
}
void reportBudget(MonthlyBudget spent, MonthlyBudget actual)
{
//Calculate the student's expenditures for the month
spent.gross = spent.house + spent.util + spent.he + spent.trans + spent.food + spent.med + spent.ins
+ spent.ent + spent.cloth + spent.misc;
cout<<"\\\tCategory\t Over/Under\\";
cout<<setw(20)<<"Housing" <<setw(8)<< actual.house - spent.house <<endl;
cout<<setw(20)<<"Uitlities" <<setw(8)<< actual.util - spent.util <<endl;
cout<<setw(20)<<"Household Expenses"<<setw(8) << actual.he - spent.he <<endl;
cout<<setw(20)<<"Transportation"<<setw(8) << actual.trans - spent.trans <<endl;
cout<<setw(20)<<"Food"<<setw(8) << actual.food - spent.food <<endl;
cout<<setw(20)<<"Medical" <<setw(8)<< actual.med - spent.med <<endl;
cout<<setw(20)<<"Insurance"<<setw(8) << actual.ins - spent.ins <<endl;
cout<<setw(20)<<"Entertainment"<<setw(8) << actual.ent - spent.ent <<endl;
cout<<setw(20)<<"Clothing"<<setw(8) << actual.cloth - spent.cloth <<endl;
cout<<setw(20)<<"Miscellaneous"<<setw(8) << actual.misc - spent.misc <<endl;
if (spent.gross <= actual.gross)
{
int under = actual.gross - spent.gross;
cout << "\\\\You have successfully stayed below your budget under: $" << under << endl;
}
else
{
int over= spent.gross - actual.gross;
cout << "\\\\You are over your monthly budget by: $ " << over <<endl;
}
}
int main()
{
MonthlyBudget actual;
actual.house = 500;
actual.util = 150;
actual.he =65;
actual.trans = 50;
actual.food = 250;
actual.med = 30;
actual.ins = 100;
actual.ent = 150;
actual.cloth = 75;
actual.misc = 50;
actual.gross = 1420;
MonthlyBudget spent;
getSpentBudget(spent);
reportBudget(spent, actual);
}