-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRankCalculation.java
More file actions
35 lines (22 loc) · 888 Bytes
/
Copy pathRankCalculation.java
File metadata and controls
35 lines (22 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.Scanner;
public class RankCalculation{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int rank;
int totalStudents;
// User Input
System.out.print("Enter Your Rank: ");
rank = sc.nextInt();
System.out.print("Enter Total Students: ");
totalStudents = sc.nextInt();
// Calculate Percentage Rank
double percentage = ((double) rank / totalStudents) * 100;
// Better Than Students
double betterThan = 100 - percentage;
// Output
System.out.println("\n===== RESULT =====");
System.out.println("Your Rank: " + rank);
System.out.println("Top Percentage: " + percentage + "%");
System.out.println("You performed better than " + betterThan + "% students");
}
}