// Drew Duffey			CSC5			Chapter 5, P.297, #19
// 
/*******************************************************************************
 * 
 * COMPUTE BUDGET
 * _____________________________________________________________________________
 * This program will take a budget amount, followed by a list of expenses, and
 * determine how over/under budget the expenses are.
 * _____________________________________________________________________________
 * INPUT
 * Budget		: The total budget given
 * Expense		: The cost of an expense
 * 
 * OUTPUT
 * Over/Under	: How over/under budget the expenses are
 * 
*******************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
	float budget;//INPUT - The total budget given
	float expense;//INPUT - The cost of an expense
	bool input;//CALC - Flag to check for the sentinel value
	float remaining;//OUTPUT - How over/under budget the expenses are
	float total;//CALC - Accumulator, the total amount of the expenses
	
	//Input total budget
	cout << "Enter your total monthly budget: ";
	cin >> budget;
	cout << endl << endl;
	input = true;
	
	//Loop for expense input
	while (input)
	{
		cout << "Please enter the amount of an expense for this month, " <<
			"or input a negative value to stop:\n";
		cin >> expense;
		
		//Check for sentinel values, then break loop once one is entered
		if (expense <= 0)
		{
			input = false;
			break;
		}
		
		//Add expense to total
		total += expense;
	}
	
	//After looping, subtract expenses from total budget
	remaining = budget - total;
	
	//Display how much over/under the user is
	cout << "\nYou have " << fixed << setprecision(2) << remaining << 
		" left, and are "; 
	
	if (remaining <= 0)
	{
		cout << "over budget.";
	}
	else
	{
		cout << "under budget.";
	}
return 0;
}