Menu
Question Index
...

Write a program to truncate to two decimals of the given number.

Input (Double number) Output
2.34567 2.34
156 156
1.8765 1.87
5.1789 5.17
0.3333 0.33
-0.087 -0.08
null null



class TruncateTwoDecimals
{
    public static void main(String s[])
    {
        Double value = 2.34567;
        Double result = truncateTwoDecimals(value);
        System.out.println("The given number "+ value+" truncate to two decimals of "+result);

    }


        public static Double truncateTwoDecimals(Double value)
        {
            Double result = null;
            return result;
    }

}

Doubts

Problems

Topic: Java Double Class And Java Float Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App