Referenced from lesson Piecewise Functions (Spring, 2021)
Alice’s code has some new elements we haven’t seen before, so let’s experiment a bit to figure out how it works! Open the Alice’s Restaurant starter file, click “Run”, and try using the cost
function in the Interactions window.
1 What does cost("hamburger") evaluate to?
2 What does cost("pie") evaluate to?
3 What if you ask for cost("fries")?
4 Explain what the function is doing in your own words.
5 What is the function’s name? Domain? Range?
6 What is the name of its variable?
7 Alice says onion rings have gone up to $3.75. Change the cost
function to reflect this.
8 Try adding menu items of your own. What’s your favorite?
9 For an unknown food item, the function produces the String "That’s not on the menu!"
Is this a problem? Why or why not?
10 Suppose Alice wants to calculate the price of a hamburger, including a 5% sales tax. Draw a Circle of Evaluation for the expression below.
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). Bootstrap:Algebra by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.