Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**
     * Formats the double as a string which is cleaned up a bit. This will return 0 for 0.0.
     * 
     * @param num Number to be formatted.
     * @return Number as a string.
     */
    private static String formatAsString(double num) {
        String res = Double.toString(num);

        if (res.endsWith(".0")) {
            res = res.substring(0, res.length() - 2);
        }

        if (res.equals("-0")) {
            res = "0";
        }

        return res;
    }
}