I need help in developing a program on \"Monthly budget\" using C++ program with
ID: 3689935 • Letter: I
Question
I need help in developing a program on "Monthly budget" using C++ program with the following instructions: (1)Math operations (for max points use built-in math functions) NOTE: Increment does not count as a math operation. (2)If / else or a switch statement (to get max points use nested if /elses)(3)Loops – 2 types (for max points use nested loops) (4)Validated user input (5)Save the data to a sequential data file and read from it (6)At least 3 functions appropriately passing parameters and returning values as needed (to get max points, overloaded function) (7)Two dimensional arrays or vectors..
Explanation / Answer
Please follow the code wit the description in the comments :
#include <iostream>
#include <iomanip>
using namespace std;
//gets users income
float getIncome()
{
float income;
cout << " Your monthly income: ";
cin >> income;
return income;
}
//gets users budgeted living expenses
float getBudgetLiving()
{
float budgetLiving;
cout << " Your budgeted living expenses: ";
cin >> budgetLiving;
return budgetLiving;
}
//Gets users actual expenses
float getActualLiving()
{
float actualLiving;
cout << " Your actual living expenses: ";
cin >> actualLiving;
return actualLiving;
}
//gets users other expenses
float getActualOther()
{
float other;
cout << " Your actual other expenses: ";
cin >> other;
return other;
}
//computes tithing
float computeTithing(float income)
{
return income * 0.10;
}
//Computes Tax
float computeTax(float a)
{
float yearlyIncome;
float yearlyTax;
float monthlyTax;
yearlyIncome = a * 12;
if (a > 336550)
yearlyTax = 91043 + 0.35*(yearlyIncome - 336550);
else if (336550 >= a > 188450)
yearlyTax = 42170 + 0.33*(yearlyIncome - 188450);
else if (188450 >= a > 123700)
yearlyTax = 24040 + 0.28*(yearlyIncome - 123700);
else if (123770 >= a > 61300)
yearlyTax = 8440 + 0.25*(yearlyIncome - 61300);
else if (61300 >= a > 15100)
yearlyTax = 15100 + 0.15*(yearlyIncome - 15100);
else (15100 >= a > 0);
yearlyTax = yearlyIncome*0.10;
monthlyTax = yearlyTax / 12;
return monthlyTax;
}
//gets users actual tithe paid
float getActualTithing()
{
float tithing;
cout << " Your actual tithe offerings: ";
cin >> tithing;
return tithing;
}
//Gets users actual Tax Paid
float getActualTax()
{
float tax;
cout << " Your actual taxes withheld: ";
cin >> tax;
return tax;
}
float budgetDifference(float income, float budgetLiving, float other)
{
float computeBudgetDifference;
float monthlyTax = computeTax(income);
float tithe = computeTithing(income);
computeBudgetDifference = income - (budgetLiving + tithe + monthlyTax + other);
return computeBudgetDifference;
}
float actualDifference(float income, float other, float actualLiving, float tax)
{
float computeActualDifference;
float tithing = computeTithing(income);
computeActualDifference = income - (other + tithing + actualLiving + tax);
return computeActualDifference;
}
//displayss budget Chart
float chartDisplay()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
float income = getIncome();
float budgetLiving = getBudgetLiving();
float actualLiving = getActualLiving();
float other = getActualOther();
float tithing = getActualTithing();
float tithe = computeTithing(income);
float tax = getActualTax();
float monthlyTax = computeTax(income);
float computeBudgetDifference = budgetDifference(income, budgetLiving, other);
float computeActualDifference = actualDifference(income, other, actualLiving, tax);
cout << " The following is a report on your monthly expenses" << endl;
cout << " Item" << setw(24) << "Budget" << setw(16) << "Actual" << endl;
cout << " =============== =============== ===============" << endl;
cout << " Income" << setw(11) << "$" << setw(11) << income << setw(5)
<< "$" << setw(11) << income << endl;
cout << " Taxes" << setw(12) << "$" << setw(11) << tax << setw(5) << "$"
<< setw(11) << monthlyTax << endl;
cout << " Tithing" << setw(10) << "$" << setw(11) << tithe << setw(5)
<< "$" << setw(11) << tithing << endl;
cout << " Living" << setw(11) << "$" << setw(11) << budgetLiving << setw(5)
<< "$" << setw(11) << actualLiving << endl;
cout << " Other" << setw(12) << "$" << setw(11) << other << setw(5)
<< "$" << setw(11) << other << endl;
cout << " =============== =============== ===============" << endl;
cout << " Difference" << setw(7) << "$" << setw(11)
<< computeBudgetDifference << setw(5) << "$" << setw(11)
<< computeActualDifference << endl;
return 0;
}
//Main display
int main()
{
cout << "This program keeps track of your monthly budget "
"Please enter the following:" << endl;
chartDisplay();
system ("PAUSE");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.