我怎么知道50个敌人进入我的双GP的次数
How can I know the number of times 50 foes into my double gp
我试过使用模数,但我对如何获得正确的数字感到困惑
public double getRewards()
{
gp = Math.random() * (1000 - 49 + 1) + 49;
for every 50 spent on groceries a 0.05 discount per gallon of gas
while(gp/50>49)//trying to get the number of times 50 goes into gp while gp is able to have 50 go into it
{
discount++;
gp=gp/50;
}
return discount;//returns the amount discounted from your total
}
您可以除以 floor(将数字四舍五入为最接近的整数)结果。例如:207 / 50 = 4.14
,和Math.floor(4.14) = 4
,所以Math.floor(207 / 50)
= 4.
gp = Math.random() * (1000 - 49 + 1) + 49;
discountNumber = Math.floor(gp / 50);
discountAmount = discountNumber * 5;
console.log('50 goes into ' + gp + ' ' + discountNumber + ' times, for a savings of ' + discountAmount + ' cents');
我试过使用模数,但我对如何获得正确的数字感到困惑
public double getRewards()
{
gp = Math.random() * (1000 - 49 + 1) + 49;
for every 50 spent on groceries a 0.05 discount per gallon of gas
while(gp/50>49)//trying to get the number of times 50 goes into gp while gp is able to have 50 go into it
{
discount++;
gp=gp/50;
}
return discount;//returns the amount discounted from your total
}
您可以除以 floor(将数字四舍五入为最接近的整数)结果。例如:207 / 50 = 4.14
,和Math.floor(4.14) = 4
,所以Math.floor(207 / 50)
= 4.
gp = Math.random() * (1000 - 49 + 1) + 49;
discountNumber = Math.floor(gp / 50);
discountAmount = discountNumber * 5;
console.log('50 goes into ' + gp + ' ' + discountNumber + ' times, for a savings of ' + discountAmount + ' cents');