This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes incrementing to next ten value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "incrementing to next ten value" Watch "incrementing to next ten value" New topic
Author

incrementing to next ten value

steve kelly
Ranch Hand

Joined: Feb 15, 2012
Posts: 47
I am sure there are a gazillion examples and a bunch of ways to do this. I was just finding something existing that does this. Basically, I want to increment to next 10 value no matter what the number is. Example if I have an int of 23 I want to return 30. If I have an int of 47 I want to return 50.
There has to be something out there does this already without playing with decimals and multiplying/rounding etc... right?
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
I recommend you write your own. Two lines, maybe one? Just think of the sense of accomplishment you'll have.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Edwin Torres
Ranch Hand

Joined: Mar 19, 2011
Posts: 55

Greg Brannon wrote:I recommend you write your own. Two lines, maybe one? Just think of the sense of accomplishment you'll have.

One:


Twitter: @realEdwinTorres
Blog: java Friendly
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
Or with the solution provided by Edwin, you don't need to.
Edwin Torres
Ranch Hand

Joined: Mar 19, 2011
Posts: 55

fred rosenberger wrote:Edwin,

Please refrain from providing solutions. We prefer to help guide people to finding their own, rather than simply spoon feeding it to them.

Got it. Thanks.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: incrementing to next ten value
 
It's not a secret anymore!