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

 

coffeeOrder


Goal: Determine the price of a coffee order based on size and extra options. Rules: Small coffee ("small") costs $3. Large coffee ("large") costs $5. If the customer wants whipped cream (hasWhip is true): Small coffee gets a $1 charge for whipped cream. Large coffee gets a $2 charge for whipped cream. Special rule: If it's "isHappyHour" (is true), whipped cream is free regardless of size.


coffeeOrder("small", false, false) → 3
coffeeOrder("small", false, true) → 3
coffeeOrder("small", true, false) → 4

...Save, Compile, Run (ctrl-enter)

public int coffeeOrder(String size, boolean hasWhip, boolean isHappyHour) { }

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: 200

Copyright Nick Parlante 2017 - privacy