File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Data Manipulation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Data Manipulation" Watch "Data Manipulation" New topic

Data Manipulation

Sam Saha
Ranch Hand

Joined: Jan 23, 2010
Posts: 104
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.

The IF statement is as below:

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

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.
I agree. Here's the link:
subject: Data Manipulation
jQuery in Action, 3rd edition