Please send questions to st10@humboldt.edu .
#include 
#include "profit.h"
using namespace std;

/*--------------------------------------------------
 Contract: main : void -> int
 Purpose: example of using a sentinel-controlled loop
          to keep calling profit until the user
          signals to stop by entering the sentinel
          value: a ticket price of -1

 Examples: it should ask the user for a ticket price
           repeatedly until the user enters a ticket 
           price of -1. A positive ticket price
           should result in a display to the screen of
           the profit for that ticket price --- a
           ticket price of -1 should halt the program.

 Compile this using:
    g++ -o sentinelEx1 countEx1.cpp profit.o revenue.o cost.o attendees.o
-----------------------------------------------------*/

int main()
{
    // local variables
    float tick_price;

    // this is my sentinel value, the special input
    //    that is my signal to STOP, already...
    const float SENTINEL = -1;

    // let's format the profit nicely...
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2); 

    cout << "Welcome to a tester for profit!" << endl;
    cout << "...that uses a SENTINEL-CONTROLLED loop" << endl;
    cout << endl;
    
    // I need to INITIALIZE ticket_price BEFORE the
    //    loop, so that I can see if it is already
    //    the sentinel value. The CLASSIC way to do
    //    this is to obtain the FIRST input BEFORE
    //    the loop...
    // (another tradition: TELL the user what the
    //    sentinel value IS... 8-)
    cout << endl;
    cout << "Enter ticket price ("
	 << SENTINEL << " to stop): ";
    cin >> tick_price;

    // WHILE the user hasn't entered the special
    //    sentinel ticket price, compute and show
    //    the profit for each non-sentinel ticket 
    //    price given.
    while (tick_price != SENTINEL)
    {
        // this is a "real" ticket price ---
        //    compute and print the profit!
        // (in a sentinel-controlled loop, get RIGHT
        //    to the LOOP ACTION)
        cout << "Profit for $" << tick_price;
        cout << " is: $" << profit(tick_price) << endl;

        // IMPORTANT: ASK for the NEXT ticket price
        //    at the END of the loop --- so NEXT thing
        //    done will be the check to see if it is
	//    the sentinel!
        cout << endl;
        cout << "Enter ticket price ("
	     << SENTINEL << " to stop): ";
        cin >> tick_price;
    }

    return 0;
}