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:
12345678910111213public class Percentage {/*** @param args the command line arguments*/public static void main(String[] args) {double totalValue = 500; //use your valuedouble gainedValue = 356; //use your valuedouble percentage = (gainedValue / totalValue) * 100;System.out.println(percentage);}}
0