Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.DecimalFormat;

public class Main {
    static DecimalFormat df = new DecimalFormat("##,####,###,##0.00");

    public static String format(double amount) {
        amount = round(amount);
        return df.format(amount);
    }

    public static double round(double amount) {
        return (Math.round(amount * 100.0D) / 100.0D);
    }

    public static double round(double amount, int i) {
        double d = Math.pow(10.0D, i);
        return (Math.round(amount * d) / d);
    }
}