一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第
10 次落地时,共经过多少米?第10 次反弹多高?
*/
public class Test1 {
public static void main(String[] args) {
double height =100;
double sum =100;
for (int i = 1; i < 11; i++) {
height = height/2 ;
sum = sum+2*height;
if(i==10){
System.out.println("共经过"+sum+"米,第十次反弹"+height+"米");
}
}
}
}
import java.util.*;
/*企业发放的奖金根据利润提成。利润(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%提成.
* 从键盘输入当月利润I,求应发放奖金总数?
*/
public class Test2 {
public static void getBonus(double profit){
double bonus = 0;
if(profit>0 && profit<=10){
bonus= profit*0.1;
}else if(profit>10 && profit<=20){
bonus=(profit-10)*0.075+10*0.1;
}else if(profit>20 && profit<=40){
bonus=10*0.1+10*0.075+(profit-20)*0.05;
}else if(profit>40 && profit<=60){
bonus=10*0.1+10*0.075+20*0.05+(profit-40)*0.03;
}else if(profit>60 && profit<=100){
bonus=10*0.1+10*0.075+20*0.05+20*0.03+(profit-60)*0.015;
}else if(profit>100){
bonus=10*0.1+10*0.075+20*0.05+20*0.03+40*0.015+(profit-100)*0.01;
}else{
bonus=0;
}
System.out.println(bonus);
}
public static void main(String[] args) {
double profit = 0;
Scanner sc =new Scanner(System.in);
while(sc.hasNext()){
profit=sc.nextDouble();
getBonus(profit);
}
}
}