MaxKrissigo - 11 months ago 26

Java Question

I've looked at many questions regarding rounding up to the nearest multiple of a number, but I can't seem to get their methods to fit with rounding up to 45 or they are in a different language. Here is a bit more of a detailed explanation if it doesn't make much sense:

`int num1 = 67;`

int num2 = 43;

//Expected results

>>round(num1) = 90

>>round(num2) = 45

Answer

It's enough to add the missing `mod45`

:

```
int upperround45(int i) {
int temp = i%45;
if (temp == 0) {
return i;
} else {
return i + 45 - temp;
}
}
```

Source (Stackoverflow)