- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeCastingEx.java
More file actions
Latest commit
14 lines (11 loc) · 510 Bytes
/
Copy pathTypeCastingEx.java
File metadata and controls
14 lines (11 loc) · 510 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
classTypeCastingEx;
publicstaticvoidmain(String[] args) {
// Set the maximum possible score in the game to 500
intmaxScore = 500;
// The actual score of the user
intuserScore = 423;
/* Calculate the percantage of the user's score in relation to the maximum available score.
Convert userScore to float to make sure that the division is accurate */
floatpercentage = (float) userScore / maxScore * 100.0f;
System.out.println("User's percentage is " + percentage);
}