Rounding a double and grouping it?

I'll explain this the best I can.

Let's say I get a user input and that is: 245, I want this to be rounded down to 200 then divided by 100 and then finally +1 so the outcome is 3 (putting it in zone 3, more below)

Basically what I need is a zoning system that goes as follows

Zone 1: 0-99
Zone 2: 100-199
Zone 3: 200-299

And so on for whatever number the user enters, so I feel rounded the number down then dividing it by 100 will be the best way to do this as I currently have it with if else statements although obviously that is finite and will only work with my predetermined zones.

Jon Skeet
people
quotationmark

Why not just divide it by 100 to start with? That will do the rounding (always towards 0) if you start off with an integer:

int zone = (input / 100) + 1;

There's no need to get into non-integer arithmetic at all here. If the user input is actually as a double, you can just cast:

int zone = ((int) input / 100) + 1;

people

See more on this question at Stackoverflow