Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some help finishing this c++ code. I need to get the last function compareExpenses to re-display the first set of budget numbers, and

I need some help finishing this c++ code. I need to get the last function compareExpenses to re-display the first set of budget numbers, and the second set of budget numbers inputted by the user, but I'm not sure how to do this. Here are the directions (in bold is what I am missing so far):

-------

Write a program that declares a MonthlyBudget structure designed with member variables to hold each of these expense categories. The program should define two MonthlyBudget structure variables budgetand spent. The first MonthlyBudget structure variable budget will contain (ie., be assigned) the budget figures given above. Pass this first structure budget variable to a function displayBudget that will display the budget categories along with the budgeted amounts.

The second MonthlyBudget structure variable spent will be passed to another function getExpenses that has the user enter the amounts actually spent in each budget category during the past month. Finally, the program should then pass both structure variables budget and spent to a function compareExpenses that displays a report indicating the amount over or under budget the student spent in each category, as well as the amount over or under for the entire monthly budget.

You may design your own user-input interface but you must use a structure and must implement the three functions listed above. The format of the monthly budgeted report should appear as similar as possible to the sample output shown below.

HINT: Use the setw and right manipulators to right-justify dollar value outputs in function compareExpenses.

INPUT VALIDATION: Do not accept negative values for the users actual expenditure inputs in function getExpenses.

------

sample output:

image text in transcribed

My code so far:

#include

#include

#include

using namespace std;

//data members

struct MonthlyBudget

{

double housing;

double utilities;

double householdExpenses;

double transportation;

double food;

double medical;

double insurance;

double entertainment;

double clothing;

double misc;

};

void displayBudget(const MonthlyBudget &);

void getExpenses(MonthlyBudget &);

void compareExpenses(MonthlyBudget budget, MonthlyBudget spent);

int main()

{

MonthlyBudget spent;

MonthlyBudget budget = {580.00, 150.00, 65.00, 50.00, 250.00, 30.00, 100.00, 150.00, 75.00, 50.00};

displayBudget(budget);

getExpenses(spent);

compareExpenses(budget, spent);

return 0;

}

void displayBudget(const MonthlyBudget &item)

{

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

}

void getExpenses (MonthlyBudget &item)

{

cout

cout

cin >> item.housing;

cout

cin >> item.utilities;

cout

cin >> item.householdExpenses;

cout

cin >> item.transportation;

cout

cin >> item.food;

cout

cin >> item.medical;

cout

cin >> item.insurance;

cout

cin >> item.entertainment;

cout

cin >> item.clothing;

cout

cin >> item.misc;

cout

}

void compareExpenses (MonthlyBudget budget, MonthlyBudget spent)

{

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

}

Here is your monthly budget: $ 580 $ 150 $ 65 Housing Utilities Household Transportation $ 50 Food Medical Insurance Entertainment $ 150 Clothing Miscellaneous 50 $ 250 $ 30 $ 100 $ 75 Total Budgeted $ 1500 Enter actual monthly expenditures for each budget category Housing Utilities: Household Transportation:$ 50 Food: Medical: Insurance: Entertainment: 120 Clothing: ERROR: You must enter a positive number Clothing: Miscellaneous: 30 S 580 $ 130 $ 50 $ 230 S 30 $ 100 $-10 $ 100 Budgeted Spent Difference Housing Utilities Household Transportation Food Medical Insurance Entertainment Clothing Miscellaneous 580.00 150.00 65.00 50.00 250.00 30.00 100.00 150.00 75.00 50.00 580.00 130.00 50.00 50.00 230.00 30.00 100.00 120.00 100.00 30.00 0.00 20.00 -15.00 0.00 20.00 0.00 0.00 -30.00 25.00 -20.00 Total 1500.00 1420.00 80.00 Congratulations! You were $80.00 under budget this month

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

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions

Question

Describe the production system found in a "lights-out" environment.

Answered: 1 week ago