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

 

fund_roundNearest


Given a decimal number, return that number rounded to the nearest whole number. The Math class method Math.round(___) returns a long, which is a whole number like int, except that it is 64-bits of storage instead of 32-bits. Typecast the answer from Math.round(___) to an int before returning it!


fund_roundNearest(1.1) → 1
fund_roundNearest(1.5) → 2
fund_roundNearest(1.7) → 2

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

public int fund_roundNearest(double x) { }

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

Post-solution available

Copyright Nick Parlante 2017 - privacy