//Jacklyn Isordia CSC5 Chapter 5, P. 297, #19
//
/**************************************************************
*
* CALCULATE BUDGET ANALYSIS
* ____________________________________________________________
* This program asks the user to enter their monthly budget
* and then accepts multiple expenses until the user enters 0.
* Finally, it reports whether the user is over or under budget.
* ____________________________________________________________
* INPUT
* budget : The total monthly budget amount
* expense : Individual expenses to be added to the total
* * OUTPUT
* totalExpenses : The sum of all expenses entered
* status : A message indicating if the user is over,
* under, or exactly on budget.
* * Formula
* totalExpenses = totalExpenses + expense
*
**************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
double budget, expense, totalExpenses = 0.0;
cout << "Enter your budget for the month: $";
cin >> budget;
cout << "Enter your expenses (enter 0 to finish):" << endl;
cout << endl;
cout << "Expense: $";
cin >> expense;
while (expense != 0) {
totalExpenses += expense;
cout << "Expense: $";
cin >> expense;
cout << endl;
}
cout << fixed << setprecision(2);
cout << "\nTotal Budget: $" << budget << endl;
cout << "Total Expenses: $" << totalExpenses << endl;
if (totalExpenses > budget) {
cout << "You are over budget by $" << (totalExpenses - budget) << "." << endl;
} else if (totalExpenses < budget) {
cout << "You are under budget by $" << (budget - totalExpenses) << "." << endl;
} else {
cout << "You are exactly on budget!" << endl;
}
return 0;
}