Monthly Budget I need to write a C++ program using Dev C++ that has a MonthlyBud
ID: 3632790 • Letter: M
Question
Monthly Budget
I need to write a C++ program using Dev C++ that has a MonthlyBudget structure designed to hold each of these expenses categories. The program should pass the structure to a function that asks 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.
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
Explanation / Answer
//Header file section
//Structure declaration
//Function prototypes
void GetBudget(Budget &);
void DiaplayReport(Budget);
//Start main
int main()
{
Budget MonthlyBudget;
//passing structure to function and get amounts spent
GetBudget(MonthlyBudget);
//Displaying Report
DiaplayReport(MonthlyBudget);
system("pause");
return 0;
}//End main
//Function Definitions
void GetBudget(Budget &b)
{
//Inputting all data members of structure
cout<<"Inputting Data of Student Budget "<<endl;
cout<<"Enter amount for Housing:";
cin>>b.Housing;
cout<<"Enter amount spent for utilities:";
cin>>b.utilities;
cout<<"Enter amount spent for HouseExpenses:";
cin>>b.HouseExpenses;
cout<<"Enter amount spent for Transportation:";
cin>>b.Transportation;
cout<<"Enter amount spent for Food:";
cin>>b.Food;
cout<<"Enter amount spent for Medical:";
cin>>b.Mediacal;
cout<<"Enter amount spent for Insurance:";
cin>>b.Insurance;
cout<<"Enter amount spent for Entertainment:";
cin>>b.Entertainment;
cout<<"Enter amount spent for Clothing:";
cin>>b.Clothing;
cout<<"Enter amount spent on Miscelleneous:";
cin>>b.Miscellaneous;
}//End of GetBudget
void DiaplayReport(Budget b)
{
float difference,Total;
cout<<"****REPORT****"<<endl;
difference=500-b.Housing;
//checking conditions for each member of structure
if(difference>=0)
cout<<"Housing Expenses is UNDER Budget"<<endl;
else if(difference<0)
cout<<"Housing Expenses is OVER Budget"<<endl;
difference=150-b.utilities;
if(difference>=0)
cout<<" Utilities Expenses is UNDER Budget"<<endl;
else if(difference<0)
cout<<" Utilities Expenses is OVER Budget"<<endl;
difference=65-b.HouseExpenses;
if(difference>=0)
cout<<"HouseHold Expenses is UNDER Budget"<<endl;
else if(difference<0)
cout<<"HouseHold Expenses is OVER Budget"<<endl;
difference=50-b.Transportation;
if(difference>=0)
cout<<"Transportation Expenses is UNDER Budget"<<endl;
else if(difference<0)
cout<<"Transportation Expenses is OVER Budget"<<endl;
difference=250-b.Food;
if(difference>=0)
cout<<"Food Expenses is UNDER Budget"<<endl;
else if(difference<0)
cout<<"Food Expenses is OVER Budget"<<endl;
difference=30-b.Mediacal;
if(difference>=0)
cout<<"Medical Expenses is UNDER Budget"<<endl;
else if(difference<0)
cout<<"Medical Expenses is OVER Budget"<<endl;
difference=100-b.Insurance;
if(difference>=0)
cout<<"Insurence Expenses is UNDER Budget"<<endl;
else if(difference<0)
cout<<"Insurence Expenses is OVER Budget"<<endl;
difference=150-b.Entertainment;
if(difference>=0)
cout<<"Entertainment Expenses is UNDER Budget"<<endl;
else if(difference<0)
cout<<"Entertainment Expenses is OVER Budget"<<endl;
difference=75-b.Clothing;
if(difference>=0)
cout<<"Clothing Expenses is UNDER Budget"<<endl;
else if(difference<0)
cout<<"Clothing Expenses is OVER Budget"<<endl;
difference=50-b.Miscellaneous;
if(difference>=0)
cout<<"Miscellaneous Expenses is UNDER Budget"<<endl;
else if(difference<0)
cout<<"Miscellaneous Expenses is OVER Budget"<<endl;
//Evaluating Total budget
}//End DisplayReport
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.