Please send questions to
st10@humboldt.edu .
// Contract: main: void -> int
//
// Purpose: ask user for the beginning ticket price and the
// ending ticket price, and then print to the
// screen the profits for each ticket price
// in that range, inclusive --- [beginning, ending] ---
// in dime increments.
//
// Examples: If the user enters a beginning price of $4 and an ending
// price of $4.3, the following would be printed to the screen:
//
// Profits for ticket prices between $4 and $4.3 (in dime increments)
// --------------------------------------------------------------
// ticket_price profit
// ------------ ------
// $4 $889.2
// $4.1 $855.3
// $4.2 $818.4
// $4.3 $778.5
//
// by: Sharon Tuttle
// last modified: 11-2-05
#include <iostream>
#include "profit.h"
using namespace std;
int main()
{
// declarations
double curr_ticket_price;
double beginning_price;
double ending_price;
const double PRICE_INCREMENT = 0.10;
// ask user for desired beginning and ending ticket prices
cout << "Please enter the beginning ticket price: ";
cin >> beginning_price;
cout << "Please enter the ending ticket price: ";
cin >> ending_price;
// print "report" headers
cout << endl
<< endl
<< "Profits for ticket prices between $"
<< beginning_price
<< " and $"
<< ending_price
<< " (in dime increments)"
<< endl
<< "--------------------------------------------------------------"
<< endl;
cout << "ticket_price" << " " << "profit" << endl;
cout << "------------" << " " << "------" << endl;
// compute and print the profits for each ticket price between
// lowest and highest ticket prices of interest in .10 increments
curr_ticket_price = beginning_price;
while (curr_ticket_price <= ending_price)
{
cout << "$" << curr_ticket_price << "\t\t"
<< "$" << profit(curr_ticket_price) << endl;
curr_ticket_price = curr_ticket_price + PRICE_INCREMENT;
}
return EXIT_SUCCESS;
}