Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Structured data Monthly Budget A student has established the following monthly b

ID: 3632336 • Letter: S

Question

Structured data

Monthly Budget

A student has established the following monthly budget:

Housing                         500.00

Utilities                         150.00

Household Expenses         65.00

Transportation                 50.00

Food                               250.00

Medical                           30.00

Insurance                        100.00

Entertainment                 150.00

Clothing                          75.00

Miscellaneous                   50.00

Write a program that has a MonthlyBudget structure designed to hold each of these expense categories. The program should pass the structure to a function that ask the user to enter the amounts spent in each budget category during a month. The program should then pass the structure to a function that displays a report indicating the amount over or under in each category, as well as the amount over or under for the entire monthly budget.

Explanation / Answer

#include <iostream>

using namespace std;

const int NUM_EXP = 10;

const int EXP_AMT = 1420;

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 *actual)

{

cout << "Enter amount for housing ";

cin >> actual->house;

cout << "Enter amount for utilities ";

cin >> actual->util;

cout << "Enter amount for household expenses ";

cin >> actual->he;

cout << "Enter amount for transportation ";

cin >> actual->trans;

cout << "Enter amount for food ";

cin >> actual->food;

cout << "Enter amount for medical ";

cin >> actual->med;

cout << "Enter amount for insurance ";

cin >> actual->ins;

cout << "Enter amount for entertainment ";

cin >> actual->ent;

cout << "Enter amount for clothing ";

cin >> actual->cloth;

cout << "Enter amount for miscellaneous ";

cin >> actual->misc;

}

void reportBudget(MonthlyBudget &actual)

{

//Calculate the student's expenditures for the month

actual.gross = 0;

actual.gross = actual.house + actual.util + actual.he + actual.trans + actual.food + actual.med + actual.ins

+ actual.ent + actual.cloth + actual.misc;

if (actual.gross <= EXP_AMT)

{

int under = EXP_AMT - actual.gross;

cout << "You have successfully stayed below your budget under: $" << under << endl;

}

else

{

int over= actual.gross - EXP_AMT;

cout << "You are over your monthly budget by: $ " << over <<endl;

}

}

int main()

{

MonthlyBudget actual;

getSpentBudget(&actual);

reportBudget(actual);

}