The problem you have described is not necessarily a problem about creating a piecewise function, but it can written down as one. To do so we need to:
- assume that Jonas sells the cups of coffee at a constant rate for each of the listed time periods,
- define the base variable (current time)
- define the changed value (this is tricky, but we can either choose the amount of beans used/lost or the amount of coffee cups sold)
Let's call the base variable t, and the changed value we will define through the function f(t). To utilize all of the listed information, let the changed value be the amount of beans used/lost. Then we need to carefully follow the described situation to define each piece of the piecewise function:
- 0 ≤ t < 7 - Jonas used no beans. f(t) = 0, 0 ≤ t < 7
- 7 ≤ t < 9 - Jonas used 80 cups worth of beans. Rate = 80/2 = 40 ⇒ f(t) = 40t + b, where b - y-intercept. We also have a point that belongs to the line describing this piece (7,0) ⇒ 0 = 40 * 7 + b ⇒ b = -280. f(t) = 40t - 280, 7 ≤ t < 9.
- 9 ≤ t < 12 - 46 cups. Rate = 46/3 ⇒ f(t) = (46/3)t + b. (9, 80) ⇒ 80 = (46/3) * 9 + b ⇒ b = -58. f(t) = (46/3)t - 58, 9 ≤ t < 12
The rest can be done similarly.