Initial commit- BAEL 2158

This commit is contained in:
Satyam 2018-09-15 22:12:47 +05:30
parent 05e1700fb7
commit 21ed59cb25
3 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1 @@
/bin/

View File

@ -0,0 +1,22 @@
package com.java.src;
import java.util.Scanner;
public class RoundUpToHundred {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double input = scanner.nextDouble();
scanner.close();
RoundUpToHundred.round(input);
}
static int round(double input) {
int i = (int) Math.round(input);
return ((i + 99) / 100) * 100;
};
}

View File

@ -0,0 +1,18 @@
package com.java.src;
import static org.junit.Assert.assertEquals;
public class RoundUpToHundredTest {
public void roundupTest() {
assertEquals("Rounded up to hundred", 100,
RoundUpToHundred.round(99));
assertEquals("Rounded down to two hundred ", 200,
RoundUpToHundred.round(200.2));
assertEquals("Returns same rounded value", 300,
RoundUpToHundred.round(300));
}
}