运行 ❯
获取
你自己
的 Java 服务器
×
更改方向
更改主题,深色/浅色
进入 Spaces
public class Main { public static void main(String[] args) { // Set the maximum possible score in the game to 500 int maxScore = 500; // The actual score of the user int userScore = 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 */ float percentage = (float) userScore / maxScore * 100.0f; // Print the result System.out.println("User's percentage is " + percentage); } }
用户的百分比是 84.6