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

Asking again to try for an answer that fits the question. Project#3(a)-Designing

ID: 3689963 • Letter: A

Question

Asking again to try for an answer that fits the question.

Project#3(a)-Designing and implementing a C++ structure data type: Monthly Budget (20 points)

A student has established the following monthly budget:

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 (Gaddis 7EO, Chapter 3) 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.

Project#3(a)-Designing and implementing a C++ structure data type: Monthly Budget (20 points)

A student has established the following monthly budget:

Budget Categories Budgeted amount Housing $ 580.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 *(DO NOT use arrays, pointers or an array of structs)

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 (Gaddis 7EO, Chapter 3) 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.

A sample test run using the Code::Block IDE-Compiler
  Here is your monthly budget:    Housing        $  580  Utilities      $  150  Household      $   65  Transportation $   50  Food           $  250  Medical        $   30  Insurance      $  100  Entertainment  $  150  Clothing       $   75  Miscellaneous  $   50  =================================================  Total Budgeted $ 1500  =================================================    Enter actual monthly expenditures for each budget category    Housing:       $ 580  Utilities:     $ 130  Household:     $ 50  Transportation:$ 50  Food:          $ 230  Medical:       $ 30  Insurance:     $ 100  Entertainment: $ 120  Clothing:      $ -10  ERROR: You must enter a positive number.  Clothing:      $ 100  Miscellaneous: $ 30                       Budgeted     Spent      Difference  =================================================  Housing           580.00      580.00        0.00  Utilities         150.00      130.00      -20.00  Household          65.00       50.00      -15.00  Transportation     50.00       50.00        0.00  Food              250.00      230.00      -20.00  Medical            30.00       30.00        0.00  Insurance         100.00      100.00        0.00  Entertainment     150.00      120.00      -30.00  Clothing           75.00      100.00       25.00  Miscellaneous      50.00       30.00      -20.00  =================================================  Total            1500.00     1420.00       80.00  =================================================    Congratulations! You were $80.00 under budget this month.    Process returned 0 (0x0)   execution time : 104.850 s  Press any key to continue.  

Explanation / Answer

Answer

#include <iostream>
#include <iomanip>
using namespace std;
struct MonthlyBudget
{
int Housing,Utilities,Household,Transportation,Food,Medical;
int Insurance,Entertainment,Clothing,Miscellaneous,total;
};

MonthlyBudget displayBudget(MonthlyBudget budget1)
{
budget1.total= budget1.Housing+budget1.Utilities+budget1.Household+budget1.Transportation+budget1.Food+budget1.Medical+budget1.Insurance+budget1.Entertainment+budget1.Clothing+budget1.Miscellaneous;
cout<<" ---Here is your monthly budget---";
cout<<" Housing $"<<budget1.Housing;
cout<<" Utilities $"<<budget1.Utilities;
cout<<" Household $"<<budget1.Household;
cout<<" Transportation $"<<budget1.Transportation;
cout<<" Food $"<<budget1.Food;
cout<<" Medical $"<<budget1.Medical;
cout<<" Insurance $"<<budget1.Insurance;
cout<<" Entertainment $"<<budget1.Entertainment;
cout<<" Clothing $"<<budget1.Clothing;
cout<<" Miscellaneous $"<<budget1.Miscellaneous;
cout<<" =================================================";
cout<<" Total Budgeted $"<<budget1.total;
cout<<" =================================================";
return budget1;
}

MonthlyBudget getExpenses(MonthlyBudget spent1)
{
cout<<" ---Enter actual monthly expenditures for each budget category---";
a:cout<<" Housing $";cin>>spent1.Housing;if(spent1.Housing<0){cout<<"ERROR: You must enter a positive number.!! "; goto a; }
b:cout<<" Utilities $";cin>>spent1.Utilities;if(spent1.Utilities<0){cout<<"ERROR: You must enter a positive number.!! "; goto b; }
c:cout<<" Household $";cin>>spent1.Household;if(spent1.Household<0){cout<<"ERROR: You must enter a positive number.!! "; goto c; }
d:cout<<" Transportation $";cin>>spent1.Transportation;if(spent1.Transportation<0){cout<<"ERROR: You must enter a positive number.!! "; goto d; }
e:cout<<" Food $";cin>>spent1.Food;if(spent1.Food<0){cout<<"ERROR: You must enter a positive number.!! "; goto e; }
f:cout<<" Medical $";cin>>spent1.Medical;if(spent1.Medical<0){cout<<"ERROR: You must enter a positive number.!! "; goto f; }
g:cout<<" Insurance $";cin>>spent1.Insurance;if(spent1.Insurance<0){cout<<"ERROR: You must enter a positive number.!! "; goto g; }
h:cout<<" Entertainment $";cin>>spent1.Entertainment;if(spent1.Entertainment<0){cout<<"ERROR: You must enter a positive number.!! "; goto h; }
i:cout<<" Clothing $";cin>>spent1.Clothing;if(spent1.Clothing<0){cout<<"ERROR: You must enter a positive number.!! "; goto i; }
j:cout<<" Miscellaneous $";cin>>spent1.Miscellaneous;if(spent1.Miscellaneous<0){cout<<"ERROR: You must enter a positive number.!! "; goto j; }
spent1.total= spent1.Housing+spent1.Utilities+spent1.Household+spent1.Transportation+spent1.Food+spent1.Medical+spent1.Insurance+spent1.Entertainment+spent1.Clothing+spent1.Miscellaneous;
return spent1;   
}

void compareExpenses(MonthlyBudget budget1,MonthlyBudget spent1)
{
cout<<" AREA Budgeted Spent Difference";
cout<<" ==================================================";
cout<<" Housing"<<setw(15)<<budget1.Housing<<setw(10)<<spent1.Housing<<setw(15)<<(budget1.Housing-spent1.Housing);
cout<<" Utilities"<<setw(13)<<budget1.Utilities<<setw(10)<<spent1.Utilities<<setw(15)<<(budget1.Utilities-spent1.Utilities);
cout<<" Household"<<setw(12)<<budget1.Household<<setw(11)<<spent1.Household<<setw(15)<<(budget1.Household-spent1.Household);
cout<<" Transportation"<<setw(7)<<budget1.Transportation<<setw(11)<<spent1.Transportation<<setw(15)<<(budget1.Transportation-spent1.Transportation);
cout<<" Food"<<setw(18)<<budget1.Food<<setw(10)<<spent1.Food<<setw(15)<<(budget1.Food-spent1.Food);
cout<<" Medical"<<setw(14)<<budget1.Medical<<setw(11)<<spent1.Medical<<setw(15)<<(budget1.Medical-spent1.Medical);
cout<<" Insurance"<<setw(13)<<budget1.Insurance<<setw(10)<<spent1.Insurance<<setw(15)<<(budget1.Insurance-spent1.Insurance);
cout<<" Entertainment"<<setw(9)<<budget1.Entertainment<<setw(10)<<spent1.Entertainment<<setw(15)<<(budget1.Entertainment-spent1.Entertainment);
cout<<" Clothing"<<setw(13)<<budget1.Clothing<<setw(11)<<spent1.Clothing<<setw(15)<<(budget1.Clothing-spent1.Clothing);
cout<<" Miscellaneous"<<setw(8)<<budget1.Miscellaneous<<setw(11)<<spent1.Miscellaneous<<setw(15)<<(budget1.Miscellaneous-spent1.Miscellaneous);
cout<<" =================================================";
cout<<" Total"<<setw(18)<<budget1.total<<setw(10)<<spent1.total<<setw(15)<<(budget1.total-spent1.total);
cout<<" =================================================";
if(budget1.total>spent1.total)
cout<<" Congratulations! You were $"<<(budget1.total-spent1.total)<<" under budget this month.";
else
cout<<" Sorry!! You were $"<<(spent1.total-budget1.total)<<" Over budget this month.";
}

int main()
{
MonthlyBudget budget,spent;
budget.Housing=580;
budget.Utilities=150;
budget.Household=65;
budget.Transportation=50;
budget.Food=250;
budget.Medical=30;
budget.Insurance=100;
budget.Entertainment=150;
budget.Clothing=75;
budget.Miscellaneous=50;
budget=displayBudget(budget);
spent=getExpenses(spent);
   compareExpenses(budget,spent);
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote