Here you can find the source of divideAndRound(int dividend, int divisor)
Parameter | Description |
---|---|
dividend | the number to be divided |
divisor | the number by which to divide |
public static int divideAndRound(int dividend, int divisor)
//package com.java2s; // it under the terms of the GNU General Public License as published by public class Main { /**//from w w w . j av a 2 s. c o m * Perform a division of the input integers, and round to the next integer * if the divisor is not a even multiple of the dividend. * * @param dividend the number to be divided * @param divisor the number by which to divide * @return the result of the division, with possible rounding */ public static int divideAndRound(int dividend, int divisor) { int result = 0; if (divisor != 0) { result = ((dividend % divisor) == 0) ? (dividend / divisor) : ((dividend / divisor) + 1); } return result; } }