Round Number to n Decimal Place
2. Round Number to n Decimal Place
//here we used format() method to print the given decimal number to 3 decimal places
//The format string %.3f specifies to print the number to 3 decimal places.
//Round number to n decimal place
package com.company;
import java.util.Stack;
public class Main {
public static void main(String[] args) {
//dicimal number
double num= 5.873324;
//print number to 3 decimal places
System.out.format("%.5f",num);
}
}
Comments
Post a Comment