Changed return type of static method to long

This commit is contained in:
Satyam 2018-09-17 19:02:35 +05:30
parent 6391285dd2
commit 14b6193fff
2 changed files with 3 additions and 3 deletions

View File

@ -12,8 +12,8 @@ public class RoundUpToHundred {
RoundUpToHundred.round(input); RoundUpToHundred.round(input);
} }
static int round(double input) { static long round(double input) {
int i = (int) Math.ceil(input); long i = (int) Math.ceil(input);
return ((i + 99) / 100) * 100; return ((i + 99) / 100) * 100;
}; };

View File

@ -6,7 +6,7 @@ import org.junit.Test;
public class RoundUpToHundredTest { public class RoundUpToHundredTest {
@Test @Test
public void givenInput_whenRoundedUp_thenTrue() { public void givenInput_whenRound_thenRoundUpToTheNearestHundred() {
assertEquals("Rounded up to hundred", 100, RoundUpToHundred.round(99)); assertEquals("Rounded up to hundred", 100, RoundUpToHundred.round(99));
assertEquals("Rounded up to three hundred ", 300, RoundUpToHundred.round(200.2)); assertEquals("Rounded up to three hundred ", 300, RoundUpToHundred.round(200.2));
assertEquals("Returns same rounded value", 400, RoundUpToHundred.round(400)); assertEquals("Returns same rounded value", 400, RoundUpToHundred.round(400));