/***********************************************************************
* Program:
*    Assignment 33, Pointers
*    Sister Unsicker, CS124
* Author:
*    Lanie Molinar
* Summary: 
*    This program asks two people for their bank account balances and the cost
*    of dinner, a movie, and ice cream on a date. It then deducts the cost 
*    from the bank account with the most money.
*
*    Estimated:  2.0 hrs   
*    Actual:     0.0 hrs
*      Please describe briefly what was the most difficult part.
************************************************************************/

#include <iostream>
using namespace std;

/***********************************************************************
* This function asks two people for their account balances and stores the 
* information.
***********************************************************************/
void getBalances(float &account1, float &account2)
{
   cout << "What is Sam's balance? ";
   cin >> account1;
   cout << "What is Sue's balance? ";
   cin >> account2;
   return;
}

/***********************************************************************
* This function compares the balances in both accounts to determine which is 
* larger.
***********************************************************************/
void compareBalances(float &account1, float account2,  float * pAccount)
{
   if (account1 > account2)
      pAccount = &account1;
   else
      pAccount = &account2;
   return;
}

/***********************************************************************
* This function prompts the user for the cost of the date and then deducts it 
* from the account with the most money.
***********************************************************************/
void date(float * pAccount)
{
   float priceDinner;
   float priceMovie;
   float priceIceCream;
   cout << "Cost of the date:\n"
      << "\tDinner:";
   cin >> priceDinner;
   cout << "\tMovie: ";
   cin >> priceMovie;
   cout << "\tIce cream: ";
   cin >> priceIceCream;
   *pAccount -= priceDinner;
   *pAccount -= (priceDinner * 0.15);
   *pAccount -= priceMovie;
   *pAccount -= priceIceCream;
   return;
}

/***********************************************************************
* This function reports the new account balances.
***********************************************************************/
void report(float account1, float account2)
{
   cout.setf(ios::fixed);
   cout.setf(ios::showpoint);
   cout.precision(2);
   cout << "Sam's balance: $" << account1 << endl;
   cout << "Sue's balance: $" << account2 << endl;
   return;
}

/**********************************************************************
*    The main function calls the other functions in the program.
***********************************************************************/
int main()
{
   float account1;
   float account2;
   float * pAccount;
   getBalances(account1, account2);
   compareBalances(account1, account2, pAccount);
   date(pAccount);
   report(account1, account2);
   return 0;
}
