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
|
#include <iostream>
#include <iomanip>
using namespace std;
/**********************************************************************
* Will ask user to input their monthly income.
***********************************************************************/
int getIncome(float &monthlyIncome)
{
cout << "\tYour monthly income: ";
cin >> monthlyIncome;
return monthlyIncome;
}
/**********************************************************************
* Will ask user for their taxes.
***********************************************************************/
int getActualTax(float &taxes)
{
cout << "\tYour actual taxes withheld: ";
cin >> taxes;
return taxes;
}
/**********************************************************************
* Will ask user for the tithing that they'll pay.
***********************************************************************/
int getActualTithing(float &tithe)
{
cout << "\tYour actual tithe offerings: ";
cin >> tithe;
return tithe;
}
/**********************************************************************
* Will ask user for their budgets living costs.
***********************************************************************/
int getBudgetLiving(float &bLivingExpenses)
{
//b for budgedted
cout << "\tYour budgeted living expenses: ";
cin >> bLivingExpenses;
return bLivingExpenses;
}
/**********************************************************************
* Will ask user for their actual living costs.
***********************************************************************/
int getActualLiving(float &aLivingExpenses)
{
//a for actual
cout << "\tYour actual living expenses: ";
cin >> aLivingExpenses;
return aLivingExpenses;
}
/**********************************************************************
* Will ask user for their actual other expenses.
***********************************************************************/
int getActualOTher(float &other)
{
cout << "\tYour actual other expenses: ";
cin >> other;
return other;
}
/**********************************************************************
* Will calculate taxes.
***********************************************************************/
float computeTax(float monthlyIncome)
{
float yearlyTax;
float yearlyIncome = monthlyIncome * 12;
if (yearlyIncome >= 0 && yearlyIncome < 15100)
yearlyTax = (yearlyIncome * .10);
else if (yearlyIncome >= 15100 && yearlyIncome < 61300)
yearlyTax = 1510 + 0.15 * (yearlyIncome - 15100);
else if (yearlyIncome >= 61300 && yearlyIncome < 123700)
yearlyTax = 8440 + 0.25 * (yearlyIncome - 61300);
else if (yearlyIncome >= 123700 && yearlyIncome < 188450)
yearlyTax = 24040 + 0.28 * (yearlyIncome - 123700);
else if (yearlyIncome >= 188450 && yearlyIncome < 336550)
yearlyTax = 42170 + 0.33 * (yearlyIncome - 188450);
else
yearlyTax = 91043 + 0.35 * (yearlyIncome - 336550);
float monthlyTax = (yearlyTax / 12);
return monthlyTax;
}
/**********************************************************************
* Will calculate their tithing.
***********************************************************************/
float computeTithing(float bTithe)
{
return (bTithe / 10);
}
/**********************************************************************
* Will display a chart of the user's expenses.
***********************************************************************/
void display(float monthlyIncome, float taxes, float bTaxes, float tithe,
float bLivingExpenses, float aLivingExpenses, float other, float bTithe)
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "\n";
cout << "The following is a report on your monthly expenses\n";
cout << "\t" << setw(22) << left << "Item"
<< setw(16) << left << "Budget"
<< "Actual\n";
cout << "\t=============== =============== ===============\n";
cout << "\t" << setw(16) << left << "Income"
<< "$" << setw(11) << right << monthlyIncome << setw(5) << right
<< "$" << setw(11) << right << monthlyIncome << "\n";
cout << "\t" << setw(16) << left << "Taxes"
<< "$" << setw(11) << right << bTaxes << setw(5) << right
<< "$" << setw(11) << right << taxes << "\n";
cout << "\t" << setw(16) << left << "Tithing"
<< "$" << setw(11) << right << bTithe << setw(5) << right
<< "$" << setw(11) << right << tithe << "\n";
cout << "\t" << setw(16) << left << "Living"
<< "$" << setw(11) << right << bLivingExpenses << setw(5) << right
<< "$" << setw(11) << right << aLivingExpenses << "\n";
cout << "\t" << setw(16) << left << "Other"
<< "$" << setw(11) << right
<< (monthlyIncome - bTaxes - bTithe - bLivingExpenses)
<< setw(5) << right << "$" << setw(11) << right << other << "\n";
cout << "\t=============== =============== ===============\n";
cout << "\t" << setw(16) << left << "Difference"
<< "$" << setw(11) << right << 0.00 << setw(5) << right
<< "$" << setw(11) << right << (monthlyIncome - taxes - tithe -
aLivingExpenses - other) << "\n";
}
/**********************************************************************
* Will call all other functions.
***********************************************************************/
int main()
{
cout << "This program keeps track of your monthly budget\n"
<< "Please enter the following:\n";
float income;
float tax;
float bTax; //budgeted Tax
float tithing;
float bTithing; //budgeted Tithing
float budgetLiving;
float actualLiving;
float actualOther;
getIncome(income);
getBudgetLiving(budgetLiving);
getActualLiving(actualLiving);
getActualTax(tax);
getActualTithing(tithing);
getActualOTher(actualOther);
bTax = computeTax(income);
bTithing = computeTithing(income);
display(income, tax, bTax, tithing, budgetLiving, actualLiving,
actualOther, bTithing);
return 0;
}
|