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 10 cookies, the cost is 25 cents per cookies.
- If an order contains 10 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 30 cookies or more, give them 10% off the order.
Remember that this discount is also removed from the profit.
Ignore negative values and 0. Only process positive values.
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. Read in the numbers from a file called data.txt, as long as the file has not
reached the end of file. 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 do the following:
- Display it's order number. First order is #1
- Display the amount of cookies ordered for this order.
- Add the number to the total cookie sales
- Calculate the profit for that order, and add it to the total
profit.
- Display the profit for the order. Remember if there was a 10% discount to remove the discount from the profit as well.
- If a discount was made, display the amount before and after, showing
the amount of the discount.
After reaching the end of file, display the sales statistics:
- Total number of orders
- Total cookies sold
- Average number of cookies sold (rounded up to the nearest integer)
- Profit
After the statistics are displayed, exit the program.