Java Calculate Percentage

Calculating percentage in java is very easy. Just follow the simple mathematics, No need to do anything extra. The math is:

Gained value / total value * 100.

That’s it. Here is the java code:

public class Percentage {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        double totalValue = 500;  //use your value
        double gainedValue = 356; //use your value 
        double percentage = (gainedValue / totalValue) * 100;
        System.out.println(percentage);
    }
}

0