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

 

busFare


Goal: Determine public transit fare based on rider category and travel time. Rules: During peak hours (isPeak is true): Standard adult fare is $4. Seniors (isSenior is true) get a discounted fare of $2. During off-peak hours (isPeak is false): Standard adult fare is $2. Seniors ride for free ($0). Special rule: Children under 5 (isChild is true) ride for free ($0) at all times, regardless of peak status.


busFare(false, false, true) → 0
busFare(true, false, true) → 0
busFare(false, true, true) → 0

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

public int busFare(boolean isPeak, boolean isSenior, boolean isChild) { }

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