A chocolate chip cookie store has a program display the statistics on cookie sales.
Fact: Cookies cost 10 cents to make,
but are sold for 25 cents.
Keep track of:
- Total number of cookies sold.
- Average number of cookies sold (rounded to the next highest integer).
- Total Profit
- If an order contains less than 12 cookies, the cost is 25 cents per cookies.
- If an order contains 12 or more cookies, the price is not 25 cents per
cookie, but 20 cents per cookie. Make sure you calculate the profit correctly.
- If an order is for 60 cookies or more, give them 5 free cookies. These
extra 5 cookies are not part of the profit for the order. In fact, they
are part of a loss. So, subtract 5 cookie's from the profit of the order
(10 cents per cookie profit loss). However keep track of the amount of cookies
ordered for the total number ordered. Keep track separately of the free
cookies.
- Free Cookies
Make functions used to:
- Read in the data from the file.
- Calculate the average number of cookies.
- Calculate the profit for an order.
- Display the statistics.
A data file called data.txt
contains cookie order quantities, one on each line. A value of 0 is used to indicate
the end of the data.
Read in the numbers from a file called data.txt, as long as a trailer value of
0 is not reached. Download the sample file to use for the
project, so that way I'll have all the same values for each student.
For each number read in (except for 0) do the following:
- Add the number to the total cookie sales
- Calculate the profit for that order, and add it to the total
profit.
After reading in a value of 0, display the sales statistics:
- Total cookies sold
- Average number of cookies sold (rounded up to the nearest integer)
- Profit
- Free cookies given away
After the statistics are displayed, exit the program.