Calculate percent between to double number - Android java.lang

Android examples for java.lang:Double

Description

Calculate percent between to double number

Demo Code


//package com.java2s;

import java.text.NumberFormat;

public class Main {
    public static String percent2(double p1, double p2) {
        String str;/*from w  w w .  j a  v  a2  s  .  com*/
        double p3 = p1 / p2;
        NumberFormat nf = NumberFormat.getPercentInstance();
        nf.setMinimumFractionDigits(0);
        str = nf.format(p3);
        return str;
    }
}

Related Tutorials