Hey guys!! Welcome to flower brackets blog. OK, today we going to talk about java calculate percentage.

Well, the word percentage was familiar when we were in tenth and twelfth grades. Calculating percentage was very crucial and important to get scholarships in top universities.

Also Read – Calculate Average of an Array in Java

So, how to calculate percentage in java?

Basically percentage is a number expressed as fraction of 100 and denoted using percent sign (%). Formula to calculate percentage is

percentage = ( a / b ) * 100 Here, a = marks obtained b = total marks

Well, now we will see java program to calculate percentage. So, let’s dig in,

#### Example:

import java.util.Scanner; public class CalculatePercentage { public static void main(String[] args) { double a = 0; double b = 0; Scanner sc = new Scanner(System.in); System.out.println("Please enter value a: "); a = sc.nextDouble(); System.out.println("Please enter value b: "); b = sc.nextDouble(); System.out.println("The percentage is: (a % of b): "); double result = a * b / 100; System.out.println(a + " % of " + b + " is " + result); } }

**Output:**

##### Conclusion

So this is all about how to calculate percentage. I hope you have understood the concept.

You can subscribe to my blog flower brackets if you haven’t already.

Do share this post if you like.