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

 

frew@mclean.com > parkingCost
prev  |  next  |  chance

A parking garage costs $2 per hour or part of an hour, with a maximum charge of $12 for the day. Determine the cost for the parking given the time. Don't use any if statements or ternaries or loops. Your answer should be one line of code (return....).


parkingCost(1) → 2
parkingCost(0.5) → 2
parkingCost(2.25) → 6

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

public int parkingCost(double time) { }

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