To calculate percentage in Java, do this:
value / total * 100.0
.Here's how you do it:
double value = 10.0;
double total = 40.0;
double percentage = value / total * 100.0;
System.out.println(percentage + "%"); // 25.0%
value / total * 100.0
.Here's how you do it:
double value = 10.0;
double total = 40.0;
double percentage = value / total * 100.0;
System.out.println(percentage + "%"); // 25.0%