id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > cashRegister
prev  |  next  |  chance

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)

public int cashRegister(int pay, boolean burger, boolean fries, boolean soda) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 220 Post-solution available

Copyright Nick Parlante 2017 - privacy