Skip to content

Commit 505c5ae

Browse files
authored
Merge pull request eugenp#5259 from Satyam0408/BAEL-2158
Initial commit- BAEL 2158
2 parents 57be700 + 38af85f commit 505c5ae

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.java.src;
2+
3+
import java.util.Scanner;
4+
5+
public class RoundUpToHundred {
6+
7+
public static void main(String[] args) {
8+
Scanner scanner = new Scanner(System.in);
9+
double input = scanner.nextDouble();
10+
scanner.close();
11+
12+
RoundUpToHundred.round(input);
13+
}
14+
15+
static long round(double input) {
16+
long i = (long) Math.ceil(input);
17+
return ((i + 99) / 100) * 100;
18+
};
19+
20+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.java.src;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
import org.junit.Test;
6+
7+
public class RoundUpToHundredTest {
8+
@Test
9+
public void givenInput_whenRound_thenRoundUpToTheNearestHundred() {
10+
assertEquals("Rounded up to hundred", 100, RoundUpToHundred.round(99));
11+
assertEquals("Rounded up to three hundred ", 300, RoundUpToHundred.round(200.2));
12+
assertEquals("Returns same rounded value", 400, RoundUpToHundred.round(400));
13+
}
14+
}

0 commit comments

Comments
 (0)