flash0382
发表于 2018-6-14 21:48:13
企业发放的奖金根据利润提成。
利润 (I) 低于或等于 10 万元时,奖金可提 10% ;
利润高于 10 万元,低于 20 万元时,低于 10 万元的部分按 10% 提成,高于 10 万元的部分,可可提成 7.5% ;
20 万到 40 万之间时,高于 20 万元的部分,可提成 5% ;
40 万到 60 万之间时高于 40 万元的部分,可提成 3% ;
60 万到 100 万之间时,高于 60 万元的部分,可提成 1.5% ,高于 100 万元时,超过 100 万元的部分按 1% 提成
1173419450
发表于 2018-6-25 19:16:47
学习一下
chinalyixuan
发表于 2018-7-1 16:22:17
{:5_91:}
yanwu
发表于 2018-7-3 10:54:36
import java.util.Scanner;
public class test2 {
public static void main(String[] args) {
System.out.println("please enter a num:");
Scanner sc = new Scanner(System.in);
double profit = sc.nextDouble();
double reward = getReward(profit);
System.out.println("reward:" + reward);
}
static double getReward(double profit) {
double reward = 0.0;
if (profit <= 10) {
reward = profit * 0.1;
} else if (profit < 20) {
reward = 10 * 0.1 + (profit - 10) * 0.075;
} else if (profit < 40) {
reward = 10 * 0.1 + 10 * 0.075 + (profit - 20) * 0.05;
} else if (profit < 60) {
reward = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + (profit - 40) * 0.03;
} else if (profit < 100) {
reward = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + (profit - 60) * 0.015;
} else {
reward = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + 40 * 0.015 + (profit - 100) * 0.01;
}
return reward;
}
}
老大徒伤悲
发表于 2018-7-3 22:23:09
想看看大神的代码
霸气小亮
发表于 2018-7-11 14:18:54
buhuiya
jay6697117
发表于 2018-7-26 08:31:24
666
MSK
发表于 2018-8-5 21:58:04
JavaScript
来个递归{:10_297:}
<script>
var array1 = ;
var array2 = [.1, .075, .05, .03, .015, .01];
function calc(n, index, result)
{
//当 利润 <= 10W 直接计算, 不递归
if (n <= array1){
result += n * array2;
return result;
}else{
//如果超过一百万, 直接计算超出部分并退出
if (index == 5){
return result + (n * array2);
}
//
n -= array1;
if (n <= array1){
result += n * array2;
return result;
}
else {
result += array1 * array2;
}
return calc(n, ++index, result)
}
}
window.onload = function (){
var i = prompt("输入利润: ")
if (! i){
alert("大哥, 输入数字, 阿拉伯那种~");
return;
}
console.log(calc(i, 0, 0));
};
</script>
MSK
发表于 2018-8-5 22:00:44
还是不二的算法好{:10_277:}
txjxp321
发表于 2018-8-10 14:05:37
学习学习
木Muk
发表于 2018-8-12 11:31:48
本帖最后由 木Muk 于 2018-8-12 12:49 编辑
{:10_256:}来个麻烦的
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>企业梯度利润提成</title>
<script src="https://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></script>
</head>
<body ng-app="app">
<br />
<center ng-controller="cal">
<label>请输入当月利润: <input type="text" ng-model="profit" />万元</label>
<p>发放奖金总数为: {{ bonus() }}万元</p>
</center>
</body>
<script type="text/javascript">
var app = angular.module('app', []);
app.controller('cal', function($scope) {
$scope.bonus = function() {
if (Number($scope.profit) <= 10) {
return String(Number($scope.profit)*0.1);
} else if (Number($scope.profit) > 10 && Number($scope.profit) <= 20) {
return String((Number($scope.profit) - 10) * 0.075 + 10 * 0.1);
} else if (Number($scope.profit) > 20 && Number($scope.profit) <= 40) {
return String((Number($scope.profit) - 20) * 0.05 + 10 * 0.075 + 10 * 0.1);
} else if (Number($scope.profit) > 40 && Number($scope.profit) <= 60) {
return String((Number($scope.profit) - 40) * 0.03 + 20 * 0.05 + 10 * 0.075 + 10 * 0.1);
} else if (Number($scope.profit) > 60 && Number($scope.profit) <= 100) {
return String((Number($scope.profit) - 60) * 0.015 + 20 * 0.03 + 20 * 0.05 + 10 * 0.075 + 10 * 0.1);
} else {
return String((Number($scope.profit) - 100) * 0.01 + 40 * 0.015 + 20 * 0.03 + 20 * 0.05 + 10 * 0.075 + 10 * 0.1);
}
}
});
</script>
</html>
确实有点重复,不过复制粘贴挺方便的
改一下吧
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>企业梯度利润提成</title>
<script src="https://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></script>
</head>
<body ng-app="app">
<br />
<center ng-controller="cal">
<label>请输入当月利润: <input type="text" ng-model="profit" />万元</label>
<p>发放奖金总数为: {{ bonus() }}万元</p>
</center>
</body>
<script type="text/javascript">
var app = angular.module('app', []);
app.controller('cal', function($scope) {
$scope.bonus = function() {
var profit = Number($scope.profit);
if (profit <= 10) {
return String(profit*0.1);
} else if (profit > 10 && profit <= 20) {
return String((profit - 10) * 0.075 + 10 * 0.1);
} else if (profit > 20 && profit <= 40) {
return String((profit - 20) * 0.05 + 10 * 0.075 + 10 * 0.1);
} else if (profit > 40 && profit <= 60) {
return String((profit - 40) * 0.03 + 20 * 0.05 + 10 * 0.075 + 10 * 0.1);
} else if (profit > 60 && profit <= 100) {
return String((profit - 60) * 0.015 + 20 * 0.03 + 20 * 0.05 + 10 * 0.075 + 10 * 0.1);
} else {
return String((profit - 100) * 0.01 + 40 * 0.015 + 20 * 0.03 + 20 * 0.05 + 10 * 0.075 + 10 * 0.1);
}
}
});
</script>
</html>
木Muk
发表于 2018-8-12 12:51:45
{:10_256:}{:10_256:}{:10_256:}<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>企业梯度利润提成</title>
<script src="https://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></script>
</head>
<body ng-app="app">
<br />
<center ng-controller="cal">
<label>请输入当月利润: <input type="text" ng-model="profit" />万元</label>
<p>发放奖金总数为: {{ bonus() }}万元</p>
</center>
</body>
<script type="text/javascript">
var app = angular.module('app', []);
app.controller('cal', function($scope) {
$scope.bonus = function() {
var bonus = 0;
var profit = Number($scope.profit);
if(profit > 100) {
bonus += (profit-100) * 0.01;
profit = 100;
}
if(profit > 60) {
bonus += (profit-60) * 0.015;
profit = 60;
}
if(profit > 40) {
bonus += (profit-40) * 0.03;
profit = 40;
}
if(profit > 20) {
bonus += (profit-20) * 0.05;
profit = 20;
}
if(profit > 10) {
bonus += (profit-10) * 0.075;
profit = 10;
}
if(profit <= 10) {
bonus += profit * 0.1;
}
return String(bonus);
}
});
</script>
</html>
说好的输入呢
chun888
发表于 2018-8-21 18:02:15
lllllllllllllllllllllllllllllllllllllllllllllllllllll
十渡
发表于 2018-8-22 22:22:04
看看
旭儿大大
发表于 2018-8-28 10:17:40
键盘输入函数怎么写哟{:10_266:}
边逗比大人
发表于 2018-9-7 18:50:48
65654
waitforlove
发表于 2018-9-20 16:11:47
<!DOCTYPE html>
<html>
<head>
<title>2</title>
<meta charset="utf-8">
</head>
<body>
<input type="text" name="利润" id="monly"><input type="button" name="计算奖金" value="计算奖金" onclick="jishu()">
<p id="op"></p>
<script type="text/javascript">
var monnum=0
function jishu(){
monnum=0
var mon=document.getElementById("monly").value;
var op=document.getElementById("op")
monly(mon)
op.innerHTML="你的奖金是:"+monnum
}
function monly(m){
// i表示剩余的钱// 将计算的奖金放入monnum
var i
if (m>100*10000){
i=100*10000
m=m-100*10000;
monnum+=m*0.01;}
else if (m>60*10000 && m<100*10000) {
i=60*10000
m=m-60*10000;
monnum+=m*0.015;}
else if (m>40*10000 && m<60*10000) {
i=40*10000
m=m-40*10000;
monnum+=m*0.03;}
else if (m>20*10000 && m<40*10000) {
i=20*10000
m=m-20*10000;
monnum+=m*0.05;}
else if (m>10*10000 && m<20*10000) {
i=10*10000
m=m-10*10000;
monnum+=m*0.075;}
else {
m=m-10*10000;
monnum+=m*0.10;}
if(i>10*10000){
monly(i)
}
}
</script>
</body>
</html>
RilliantLin
发表于 2018-9-21 10:26:05
{:5_90:}
a211827754
发表于 2018-9-23 10:18:30
emm
江南尘缘
发表于 2018-9-23 20:29:01
支持