写一个JAVA小程序

如题所述

第1个回答  推荐于2016-04-24
//没有格式化保留几位小数什么的 ,需要的话 说,我改
import java.util.Scanner;

public class Test {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

System.out.println("请输入当前的利润(万元)");
Scanner sc=new Scanner(System.in);
double money=sc.nextDouble();
if(money<=10){
System.out.println("当前奖金应该为:"+(money*(1-0.9))+"万元");
}else if(money>10 && money <=20){
System.out.println("当前奖金应该为:"+(10*(1-0.9)+(money-10)*0.075)+"万元");
}else if(money>20 && money <=40){
System.out.println("当前奖金应该为:"+(10*(1-0.9)+10*0.075+(money-20)*0.05)+"万元");
}else if(money>40 && money <=60){
System.out.println("当前奖金应该为:"+(10*(1-0.9)+10*0.075+(20*0.05)+(money-40)*0.03)+"万元");
}else if(money>60 && money <=100){
System.out.println("当前奖金应该为:"+(10*(1-0.9)+10*0.075+(20*0.05)+20*0.03+(money-60)*0.015)+"万元");
}else if(money >100){
System.out.println("当前奖金应该为:"+(10*(1-0.9)+10*0.075+(20*0.05)+20*0.03+40*0.015+(money-100)*0.01)+"万元");
}
}

}本回答被提问者采纳
第2个回答  2015-09-18
import java.io.DataInputStream;
public class Bouns {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
DataInputStream din = new DataInputStream(System.in);
System.out.print("输入利润:");
double profit = Double.parseDouble(din.readLine());
System.out.println("奖金:"+Bouns.bouns(profit));
}
public static double bouns(double profit){
double bouns;
if(profit<=100000){
bouns = profit * 0.1;
return bouns;
}else{
bouns = 100000 * 0.1;
}
if(profit<=200000){
bouns += (profit - 100000)  * 0.075;
return bouns;
}else{
bouns += (200000 - 100000) * 0.075;
}
if(profit<=400000){
bouns += (profit - 200000) * 0.05;
return bouns;
}else{
bouns += (400000 - 200000) * 0.05;
}
if(profit<=600000){
bouns += (profit - 400000) * 0.03;
return bouns;
}else{
bouns += (600000 - 400000) * 0.03;
}
if(profit<=1000000){
bouns += (profit - 600000) * 0.015;
return bouns;
}else{
bouns += (1000000 - 600000) * 0.015;
}
bouns += (profit - 1000000) * 0.01;
return bouns;
}
}

第3个回答  2015-09-18
这个用switch case或者用if else。
相似回答