//Charlotte Davies-Kiernan CS1A Chapter 5 P. 297 #19
//
/******************************************************************************
*
* Analyze Budget
* ___________________________________________________________________________
* This program will prompt the user to enter an ideal amount for a budget
* per month. The program then allows the user to enter however many expenses
* they want until they enter 0 to calculate whether they are under or over
* their budget
*
* Formula that will be used:
* totalAmount = budget - totalExpenses
* ___________________________________________________________________________
* Input
* budget //Budget user decides to input
* expenses //Expenses inputted by user
*
* Output
* totalExpenses //Total Amount of Expenses
*****************************************************************************/
#include <iostream>
using namespace std;
int main()
{
float budget; //INPUT - budget user has decided to enter
float expenses; //INPUT - number of expenses user has made
float totalAmount; //OUTPUT - difference between expenses and budget
float totalExpenses; //OUTPUT - total amount of expenses
//
//Get Inputs
cout << "Enter the amount you have budgeted for this month: $" << endl;
cin >> budget;
cout << "Enter your expenses one by one (enter 0 when finished):" << endl;
do {
cout << "Expense:$ ";
cin >> expenses;
if (expenses >0)
totalExpenses += expenses;
} while (expenses !=0);
cout << "\nTotal expenses: $" << totalExpenses << endl;
//
//
if (totalExpenses > budget)
cout << "You are over budget by $" << totalExpenses - budget << endl;
else if (totalAmount < budget)
cout << "You are under budget by $" << totalExpenses - budget << endl;
else
cout << "You are exactly on budget!" << endl;
return 0;
}