For each value read your program should display the


Math.floor may be used to round a number to a specific decimal place. The statement

y = Math.floor( x * 10 + 0.5 ) / 10;

rounds x to the tenths position (i.e., the first position to the right of the decimal point).
The statement

y = Math.floor( x * 100 + 0.5 ) / 100;

rounds x to the hundredths position (i.e., the second position to the right of the decimal point). Write an application that defines four methods for rounding a number x in various ways:

a) roundToInteger( number )

b) roundToTenths( number )

c) roundToHundredths( number )

d) roundToThousandths( number )

For each value read, your program should display the original value, the number rounded to the nearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hundredth and the number rounded to the nearest thousandth.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: For each value read your program should display the
Reference No:- TGS01250981

Now Priced at $20 (50% Discount)

Recommended (99%)

Rated (4.3/5)