1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
#include <iostream>
using namespace std;
struct MonthlyBudget
{
double housing,
utilities,
householdExpenses,
transportation,
food,
medical,
insurance,
entertainment,
clothing,
miscellaneous;
MonthlyBudget(double h= 0, double u= 0, double he = 0, double t= 0, double f= 0, double m= 0, double i= 0, double e= 0, double c= 0, double misc= 0)
{
housing = h;
utilities = u;
householdExpenses = he;
transportation = t;
food = f;
medical = m;
insurance = i;
entertainment = e;
clothing = c;
miscellaneous = misc;
}
};
void equations()
{
double total;
double user;
double fixed;
total.housing = user.housing - fixed.housing;
}
void getAmount(MonthlyBudget &);
void displayAmount(MonthlyBudget &, MonthlyBudget &);
int main()
{
MonthlyBudget fixed(500.00, 150.00, 65.00, 50.00, 250.00, 30.00, 100.00, 150.00, 75.00, 50.00);
MonthlyBudget user;
getAmount(user);
displayAmount(user, fixed);
return 0;
}
void getAmount(MonthlyBudget &user)
{
cout << endl << "Please enter your monthly expenses:\n";
cout << endl << "Housing: ";
cin >> user.housing;
cout << endl << "Utilities: ";
cin >> user.utilities;
cout << endl << "Household Expenses: ";
cin >> user.householdExpenses;
cout << endl << "Transportation: ";
cin >> user.transportation;
cout << endl << "Food: ";
cin >> user.food;
cout << endl << "Medical: ";
cin >> user.medical;
cout << endl << "Insurance: ";
cin >> user.insurance;
cout << endl << "Entertainment: ";
cin >> user.entertainment;
cout << endl << "Clothing: ";
cin >> user.clothing;
cout << endl << "Miscellaneous: ";
cin >> user.miscellaneous;
}
void displayAmount(MonthlyBudget &user, MonthlyBudget &fixed)
{
cout << endl << "Here are your individual totals for the month:\n";
cout << endl << "Housing: " << "$ " << user.housing << endl;
if (user.housing > fixed.housing)
{
cout << "Your housing expenses was over the budget, by value (total.housing)\n";
}
else
{
cout << "Your housing expenses was under the budget\n";
}
cout << endl << "Utilities: " << "$ "<< user.utilities << endl;
if (user.utilities > fixed.utilities)
{
cout << "Your utilities expenses was over the budget\n";
}
else
{
cout << "Your utilities expenses was under the budget\n";
}
cout << endl << "Household Expenses: " << "$ " << user.householdExpenses << endl;
if (user.householdExpenses > fixed.householdExpenses)
{
cout << "Your household expenses was over the budget\n";
}
else
{
cout << "Your household expenses was under the budget\n";
}
cout << endl << "Transportation: " << "$ " << user.transportation << endl;
if (user.transportation > fixed.transportation)
{
cout << "Your transportation expenses was over the budget\n";
}
else
{
cout << "Your transportation expenses was under the budget\n";
}
cout << endl << "Food: " << "$ " << user.food << endl;
if (user.food > fixed.food)
{
cout << "Your food expenses was over the budget\n";
}
else
{
cout << "Your food expenses was under the budget\n";
}
cout << endl << "Medical:: " << "$ " << user.medical << endl;
if(user.medical > fixed.medical)
{
cout << "Your medical expenses was over the budget\n";
}
else
{
cout << "Your medical expenses was under the budget\n";
}
cout << endl << "Insurance: " << "$ " << user.insurance << endl;
if (user.insurance > fixed.insurance)
{
cout << "Your insurance expenses was over the budget\n";
}
else
{
cout << "Your insurance expenses was under the budget\n";
}
cout << endl << "Entertainment: " << "$ " << user.entertainment << endl;
if (user.entertainment > fixed.entertainment)
{
cout << "Your entertainment expenses was over the budget\n";
}
else
{
cout << "Your entertainment expenses was under the budget\n";
}
cout << endl << "Clothing: " << "$ " << user.clothing << endl;
if (user.clothing > fixed.clothing)
{
cout << "Your clothing expenses was over the budget\n";
}
else
{
cout << "Your clothing expenses was under the budget\n";
}
cout << endl << "Miscellaneous: " << "$ " << user.miscellaneous << endl;
if (user.miscellaneous > fixed.miscellaneous)
{
cout << "Your miscellaneous expensees was over the budget\n";
}
else
{
cout << "Your miscellaneous expenses was under the budget\n";
}
double userBudget = user.housing + user.utilities + user.householdExpenses + user.transportation + user.food + user.medical + user.insurance + user.entertainment + user.clothing + user.miscellaneous;
double fixedBudget = fixed.housing + fixed.utilities + fixed.householdExpenses + fixed.transportation + fixed.food + fixed.medical + fixed.insurance + fixed.entertainment + fixed.clothing + fixed.miscellaneous;
cout << endl << "Total expenses for the month: $ " << userBudget;
if(userBudget > fixedBudget)
{
cout << endl << "Your expenses exceed your monthly average budget\n";
}
else
{
cout << endl << "Your expenses are under your monthly average budget\n";
}
}
|