Kotlinlearncs.online LogoJava
Return to List

Test Writing: Round Sum

Imported By: Geoffrey Challen
/ Version: 2021.7.0

For this problem, we'll round an int value up to the next multiple of 10 if its rightmost digit is 5 or more, so 15 rounds up to 20. Alternately, round down to the previous multiple of 10 if its rightmost digit is less than 5, so 12 rounds down to 10. Given three positive ints, return the sum of their rounded values. Complete and use the private helper method round10 and use it to perform the rounding so that you don't need to repeat the same code three times.

Test Design Challenge

You're challenge is to write tests for this problem described above.

  • Provide a method named test that accepts no arguments and does not return a value.
  • If the implementation of the class described above is incorrect, your test method should throw an exception.
  • If it is correct, do not throw an exception.
  • You may want to use Java's assert method
private int round10(int value) {
return 0;
}
int roundSum(int first, int second, int third) {
return 0;
}