Java arithmetics for calculating a percentage

后端 未结 8 711
一个人的身影
一个人的身影 2021-01-21 14:00

I have a little problem in my java application.

I have to calculate the score they have when they finish, I use this method:

public Float ScoreProcent(in         


        
8条回答
  •  臣服心动
    2021-01-21 14:25

    Try this:

    num = (float) (100 * (float) correct / (float) questions);
    

    or

    num = (correct * 100.0) / questions;
    

提交回复
热议问题