The Week's Sales
Time for another project! This checkpoint puts the loops and arrays from the last two lessons to work, together with everything you learned before them. As in the first checkpoint, the instructions say what the program should print, and how you write it is up to you. And as there, each exercise also runs your program with other data, so it has to work everything out from the array.
The project. In the summer holidays, you sell lemonade at a stand. Over three exercises, your program will turn a week of sales into a report: how many cups you sold, how much you earned and when you could afford what you're saving up for, and finally which days in a row sold the most.
The data. The array cups holds how many cups of lemonade you sold on each day of the week: 12 on the first day, 18 on the second, and so on. The report numbers the days from 1, the way people count them, while the indexes of the array start at 0.
The task. For this week, the report starts like this:
Cups sold: 122
Average: 17.4 cups a day
Best day: day 5 (30 cups)The average is the total divided by the number of days, with one decimal place. Get the number of days from the array with sizeof, don't write 7 into your code: then the program stays right when you add another day. And print each line only once, after the loop has gone through the whole week.
When your program works, try changing the sales of a day, or add an eighth day to the array, and check the report again. The exercise does that too.
Instructions
Print how many cups you sold in the whole week, and the average per day.
Print the best day: its number, and how many cups you sold on it.
Start programming for free
1/3