在这里输入图像描述我正在尝试创建一个考虑权重因子的平均计算器程序&当单击jbutton时不断更新jlabels。不幸的是,当我运行这个程序时,我似乎无法得到标签的准确结果。我也尝试过使用+=赋值,但结果是一样的,我是新来的堆栈溢出,我知道这段代码是直接从gui源代码,所以我提前为任何问题道歉。
userScore = Double.parseDouble(txtUserScore.getText());
userWeightFactor = Double.parseDouble(txtUserWeightFactor.getText());
double totalWeight = 0;
double totalAverage = 0;
while (totalWeight <= 100)
{
totalWeight = totalWeight + userWeightFactor;
lblWeightFactor.setText(String.valueOf(totalWeight));
double average = userScore * userWeightFactor / 100;
totalAverage = totalAverage + average;
lblWeightedAverage.setText(String.valueOf(totalAverage));
}
暂无答案!
目前还没有任何答案,快来回答吧!