Round Up The Result Of Integer Division | Java Programs

Output:

*** Rounding Up Integer Division ***

Number 1 = 10
Number 2 = 3

Their division is : 3.333

Rounding Up : 3

Click Here For Java Online Compiler

Solution:

class WholeFractionalOfDouble {

    public static void main(String[] args) {
        double anyNumber = 12.368;
        double fractional_part = anyNumber % 1;
        double integral_part = anyNumber - fractional_part;
        System.out.println("*** Whole and Fractional Parts In A Double" + "\n");
        System.out.println("Original number is : " + anyNumber + "\n");
        System.out.println("Integral part      : " + integral_part);
        System.out.println("Fractional part    : " + fractional_part);
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon