#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
usingnamespace std;
//number of catagories
constint NUM_EXP = 10;
//the monthly income
constint EXP_AMT = 1500;
struct MonthlyBudget {
int housing;
int utilities;
int householdExpenses;
int transporation;
int food;
int medical;
int insurance;
int entertainment;
int clothing;
int miscellaneous;
int gross;
int under;
int over;
};
int main()
{
do
{
MonthlyBudget actual;
cout << "Enter amount for housing ";
cin >> actual.housing;
cout << "Enter amount for utilities ";
cin >> actual.utilities;
cout << "Enter amount for household expenses ";
cin >> actual.householdExpenses;
cout << "Enter amount for transportation ";
cin >> actual.transporation;
cout << "Enter amount for food ";
cin >> actual.food;
cout << "Enter amount for medical ";
cin >> actual.medical;
cout << "Enter amount for insurance ";
cin >> actual.insurance;
cout << "Enter amount for entertainment ";
cin >> actual.entertainment;
cout << "Enter amount for clothing ";
cin >> actual.clothing;
cout << "Enter amount for miscellaneous ";
cin >> actual.miscellaneous;
//Calculate the student's expenditures for the month
actual.gross =(actual.housing + actual.utilities + actual.householdExpenses + actual.transporation + actual.food + actual.medical + actual.insurance + actual.entertainment + actual.clothing + actual.miscellaneous);
//To see if you are under budget
if (actual.gross < EXP_AMT)
{
actual.under = EXP_AMT - actual.gross;
cout << "You are below your monthly budget so you saved $ " << actual.under << endl;
}
//To see if you are right at your budget
if (EXP_AMT == actual.gross)
{
cout << "You are right at your monthly budget";
}
//To see if you are over the budget
if (EXP_AMT < actual.gross)
{
actual.over = actual.gross - EXP_AMT;
cout << "You are over your monthly budget by: $ " << actual.over <<endl;
}
{
ofstream file_("budget.txt");
if(file_.is_open () ){
//print to show how much you saved
if (actual.gross < EXP_AMT)
{
actual.under = EXP_AMT - actual.gross;
file_<< "You are below your monthly budget so you saved $ " << actual.under << endl;
}
//print if you are at the budget
if (EXP_AMT == actual.gross)
file_<< "You are right at your monthly budget";
}
//print if you are over budget
if (EXP_AMT < actual.gross)
{
actual.over = actual.gross - EXP_AMT;
file_<< "You are over your monthly budget by: $ " << actual.over <<endl;
file_.close();
}
std::cin.get ();
while (actual.gross <=1500);
system ("pause");
return 0;
}