Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Locale;

public class Main {
    public static String formatPercent(long completed, long total) {
        if (completed <= 0 || total <= 0) {
            return "0.0%";
        }
        final float c = completed;
        final float t = total;
        try {
            return String.format(Locale.US, "%.1f%%", c / t * 100);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "0.0%";
    }
}