Zebra0.com

java mathHow many busses?

How many busses?

An organization wants to take a trip. We need enough busses to fit everyone. (We can't tell a few people that they can't go.)

Notice that the ceil function will give us the correct number of busses. However, if we divide 30/25 we will get just one. To find the number of busses we need the ceiling (Math.ceil) function. However, ceil requires a double as an argument. Multiplying an int by 1.0 converts it to double. We could also use Math.ceil((double)numPeople/numSeats) to cast to double.

How many people are going:20
How many seats are there on a bus:16
You will need 2 busses.