about | help | code help+videos | done | prefs |
Write a method to act as a cash register at a fast-food restaurant. The input parameter 'pay' indicates the amount of money the customer is giving you. The input parameters 'burger', 'fries', and 'soda' are 'true' if the customer is purchasing each of these items, 'false' otherwise. The costs are: burger is $5, fries are $3, and soda is $2. Return how much change the customer will get back. For example, if the customer pays $10 and only buys fries, he or she will get back $7. cashRegister(50, true, true, true) → 40 cashRegister(10, true, false, true) → 3 cashRegister(10, true, true, false) → 2 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 220 Post-solution available
Copyright Nick Parlante 2017 - privacy