Skip to content

Commit 21ed59c

Browse files
committed
Initial commit- BAEL 2158
1 parent 05e1700 commit 21ed59c

3 files changed

Lines changed: 41 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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
9+
Scanner scanner = new Scanner(System.in);
10+
double input = scanner.nextDouble();
11+
scanner.close();
12+
13+
RoundUpToHundred.round(input);
14+
}
15+
16+
static int round(double input) {
17+
18+
int i = (int) Math.round(input);
19+
return ((i + 99) / 100) * 100;
20+
};
21+
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.java.src;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
public class RoundUpToHundredTest {
6+
public void roundupTest() {
7+
8+
assertEquals("Rounded up to hundred", 100,
9+
RoundUpToHundred.round(99));
10+
11+
assertEquals("Rounded down to two hundred ", 200,
12+
RoundUpToHundred.round(200.2));
13+
14+
assertEquals("Returns same rounded value", 300,
15+
RoundUpToHundred.round(300));
16+
17+
}
18+
}

0 commit comments

Comments
 (0)