I have written multiple IF statement in my code. Now I want to write a function which will do the same job as the IF statement is doing and I wanted to clean that big IF statement with this function call. I am new in Java and I am wondering if someone can give me a sample function which I can refer to implement this. I would really appreciate your help.
Was that supposed to be the answer to the homework question in your previous post, where you had to round a value to the nearest integer ending in 5?
Then yes, that's the hard way to do it. It is possible to do that in one line of code rather than a big if-statement. (Although your code is off by 0.1 in the way it works.)
However as to whether someone can give you that line of code... no, sorry, that isn't the way we work here. But let me give you a hint: since the rounded results are 145, 155, 165, 175 and so on, they are separated by 10. So the basis of the calculation is rounding a value to the nearest 10, and then you have to modify that to get a result ending in 5.