Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
See the bottom for how to submit your work.
The second simplest calculatorDebug your code until it runs correctly. Circle below how you wrote your code.
|
For each expression denoted left, fill in the type
of the expression.
|
hw.cpp
to figure out how many days it took you to eat all of your cookies.
Specifically, your program will first read in the total number of cookies to fill up the jar, and then read in the number of cookies eaten day-by-day, starting with day 1. Once the cookies in the jar are gone, you will display the total number of cookies eaten, the total number of days it took, and the number eaten on the user's piggiest day (i.e. when the most were eaten). If the user tries to eat more cookies than were in the jar originally, you should instead display the message "Not enough cookies!", and exit.
Assume that all the numbers typed in will be positive integers. Your program should always say "cookies" and "days" even if there is one cookie or one day; grammar rules go out the window come exam time! Finally, you must follow the input and output conventions below exactly.
~/$ ./hw How many cookies? 11 Cookies eaten on day 1: 2 Cookies eaten on day 2: 5 Cookies eaten on day 3: 1 Cookies eaten on day 4: 3 You ate 11 cookies over 4 days. On your piggiest day you ate 5 cookies. |
~/$ ./hw How many cookies? 5 Cookies eaten on day 1: 5 You ate 5 cookies over 1 days. On your piggiest day you ate 5 cookies. |
~/$ ./hw How many cookies? 19 Cookies eaten on day 1: 5 Cookies eaten on day 2: 10 Cookies eaten on day 3: 5 Not enough cookies! |
~/bin/submit -c=IC210 -p=hw08 hw.cpp