public class Main {
public static void main(String[] args) {
// 设置游戏最高分为 500
int maxScore = 500;
// 用户实际得分
int userScore = 423;
/* 计算用户得分占最高分的百分比。
将 userScore 转为 float 类型以确保除法运算的精确性 */
float percentage = (float) userScore / maxScore * 100.0f;
// 打印结果
System.out.println("用户得分百分比是 " + percentage);
}
}