如何计算缺失的数字,以便将其添加到某个变量时,结果将等于或大于另一个变量。
- 发起人:10
- 批评者:2
- 总数:12
- 平均:66.67
- 目标:75
- 你需要 ???促销员达到您的目标。
如果平均值小于目标,我想找出我需要多少促销员。如何计算缺失的数字,以便当我将其添加到发起人时,平均值的结果等于或大于目标。
谢谢你!
function missingNum() {
var xPromoter = '';
var x = 10;
var y = 2;
var target = 75;
var z = x + y;
var v = ((x - y) / z) * 100;
average = Math.round(v * 100) / 100;
if (average<target) //how to increment x so that average => target
document.write("Promoter:" + "\n" + x + "<br>");
document.write("Detractor:" + "\n" + y + "<br>" );
document.write("Total:" + "\n" + z + "<br>" );
document.write("Average:" + "\n" + average + "<br>" );
document.write("Target:" + "\n" + target + "<br>" );
document.write("You need " + "\n" + xPromoter + "Promoters to reach your Target." );
}