- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Java program to calculate the percentage

Percent means percent (hundreds), i.e., a ratio of the parts out of 100. The symbol of a percent is %. We generally count the percentage of marks obtained, return on investment etc. The percentage can go beyond 100% also.

For Example, assuming that we have total and a part. So we say what part is what percent of total and should be calculated as −

percentage = ( part / total ) × 100

## Algorithm

1. Collect values for part and total 2. Apply formula { percentage = ( part / total ) × 100 } 3. Display percentage

## Example

import java.util.Scanner; public class Percentage { public static void main(String args[]){ float percentage; float total_marks; float scored; Scanner sc = new Scanner(System.in); System.out.println("Enter your marks ::"); scored = sc.nextFloat(); System.out.println("Enter total marks ::"); total_marks = sc.nextFloat(); percentage = (float)((scored / total_marks) * 100); System.out.println("Percentage ::"+ percentage); } }

## Output

Enter your marks :: 500 Enter total marks :: 600 Percentage ::83.33333

- Related Articles
- How to calculate percentage of any value ?
- Java Program to Calculate the Compound Interest
- Java program to calculate mode in Java
- Java Program to calculate the power using recursion
- Java program to calculate the average of numbers in Java
- Java program to calculate student grades
- Java Program to Calculate Standard Deviation
- Java Program to calculate Compound Interest
- Java Program to Calculate Simple Interest
- Java program to calculate the product of two numbers
- Java program to calculate the power of a number
- Java Program to Calculate the intersection of two sets
- Java Program to Calculate the difference between two sets
- Java Program to Calculate the Execution Time of Methods
- Java Program to Calculate the Sum of Natural Numbers

Advertisements