Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.math.BigDecimal;

public class Main {
    public static void main(String args[]) {
        double r = 3.1234567;
        int decimalPlace = 2;
        BigDecimal bd = new BigDecimal(r);
        bd = bd.setScale(decimalPlace, BigDecimal.ROUND_UP);
        r = bd.doubleValue();
        System.out.println(r);
    }
}