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

 

konstans@stuy.edu > roundToPlace
prev  |  next  |  chance

Math.round(value) only rounds to the nearest integer. In order to round to another decimal place, you have to shift the decimal point by multiplying or dividing first. roundToPlace(value, place) will use place to determine which decimal place to round to. 0: standard round to ones place. 1: round to tenths. -1: round to tens. etc. Hint: Use the place as an exponent for a power of 10. You can use Math.pow(base,expt)


roundToPlace(1.2345, 0) → 1.0
roundToPlace(1.5, 0) → 2.0
roundToPlace(1.2345, 1) → 1.2

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

double roundToPlace(double value, int place){ }

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

Copyright Nick Parlante 2017 - privacy