CSC133 Introduction to CS Using C++
Lab 5

In this lab you will write a program to compute the profit earned on a well. A well may be producing oil, gas, or nothing.

Description

Input

  1. a character representing the substance produced by the well (‘O’ or ‘o’ for an oil producing well, ‘G’ or ‘g’ for a gas producing well, ‘N’ or ‘n’ for a well that is not producing anything)
  2. a number representing the cost of drilling the well

If the well is producing oil or gas, there will be one additional input: a number representing the number of barrels produced.

Processing

If the character entered for the substance produced by the well is invalid (any character other than ‘G’, ‘g’, ‘O’, ‘o’, ‘N’, ‘n’) print an error message and don’t do any of the calculations.

Otherwise, compute the revenue produced by the well and the profit earned by the well:

If the well is producing nothing, then the revenue is zero.
If the well is producing gas or oil, then the revenue is the amount produced multiplied by the value per barrel. Oil is worth $28.50 per barrel and gas is worth $22.40 per barrel.
The profit is the revenue produced minus the cost of the well.

Output

The program will print your name, course and section number, and the lab number. If the user enters an invalid value for the substance produced, the only other output is an error message. Otherwise, the rest of the output is:

  1. the cost of the well
  2. the revenue produced
  3. the profit
  4. If the profit is more than $50,000, print a message stating that this well is a gusher.

Instructions

To write this program you will create the following functions:

In your program, use named constants for the value of a barrel of oil, the value of a barrel of gas, and the amount of profit needed to be a gusher. Define these constants after the #include statements and before main.


Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2002