UT源码+105032014018

  设计佣金问题的程序

commission方法是用来计算销售佣金的需求,手机配件的销售商,手机配件有耳机(headphone)、手机壳(Mobile phone shell)、手机贴膜(Cellphone screen protector)三个部件,每个部件单价为:耳机80元,手机壳10元,手机贴膜8元,每月月末向制造商报告销量,制造商根据销量给销售商佣金。如果销售额不足1000元按10%提取佣金,1000-1800元部分按15%提取佣金,超过1800元部分按20%提取佣金。

 程序要求:

1)先显示“请分别输入三种手机配件的销售情况:”

2)不满足条件,返回:“输入数量不满足要求”,返回重新输入;

3)条件均满足, 则返回佣金额。返回等待输入。

    float  commission (int headphone, int shell, int protector)

public class MonyCount {

/**
* @param args
*/
//用于判断输入是否正确
static boolean charge(String headphone, String shell, String protector){
if(Integer.valueOf(headphone).intValue()<0||
Integer.valueOf(shell).intValue()<0||
Integer.valueOf(protector).intValue()<0){
System.out.println("输入数量不满足要求");
return false;
}else{
return true;
}
}
static //计算佣金的公式
float commission (String Headphone, String Shell, String Protector){
//实现字符串到数字的转化
int headphone=0;
int shell=0;
int protector=0;
try {
headphone = Integer.valueOf(Headphone).intValue();
shell= Integer.valueOf(Shell).intValue();
protector= Integer.valueOf(Protector).intValue();
} catch (NumberFormatException e) {
e.printStackTrace();
}

int total=0;
float money=0;
total=80*headphone+10*shell+8*protector;
if(total<1000){
money=(float) (total*0.1);
}
if(total>=1000&&total<1800){
money=(float) (total*0.15);
}
if(money>=1800){
money=(float) (1800*0.15+(total-1800)*0.2);
}
return money;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
String headphone;
String shell;
String protector;
float count;//用于输出计算后得到的佣金
//分别对输入的数值进行校验
while(true){
System.out.println("请分别输入三种手机配件的销售情况:");
headphone=sc.next();
shell=sc.next();
protector=sc.next();
//改函数用于判断输入是否符合规范
if(!charge(headphone,shell,protector)){
continue;
}
count=commission(headphone,shell,protector);
System.out.println("应支付的佣金为:"+count);
}
}

}

  

转载于:https://www.cnblogs.com/leezoey/p/6530136.html

HS-870P Half-size Pentium M CPU Card Intel Pentium M socket479 w i th DDR33 3 Onboard VGA, Gigabit LAN, Compact Flash LVDS, USB2.0 Form Factor Half-size PISA bus CP U Card CPU Intel Socket479/BGA479 for Pentium M / Celeron M processor Memory 1 x DDR266/333 SDRAM up to 1GB Chipset Intel 82855GME and ICH4 Real Ti me Clock Chips et integrated R T C with onboard lithium battery Watchdog Ti mer Generates a system reset with internal timer for 1 m in ~ 255min Power Management ACPI 1.0 compliant, supports power saving mode with ATX PSU PCI Enhanced IDE Dual UltraATA/100 IDE channels up to 4 ATAPI devices Onboard 40-pin IDE1 connector & 44-pin IDE2 connector VGA Interface Intel 855GME integrated Extreme Graphic 2 Technology Vi deo Memory Up to 64MB shared with system memory LCD interface 24-bit dual channel LV DS interface up to 1600 x 1200 of resolution Audio Interface Intel ICH4 integrated with Realtek ALC201A AC97 Codec LAN Interface Intel 82540EM Gigabit Ethernet Controller Solid State Disk 1 x Compact Flash Socket IDE1 supports DiskOnModule with +5V power supply GPIO interface Onboard programmable 8-bit Digital I/O interface Internal I/O Port 1 x internal p arallel and IrDA ports and 1 x 5-pin LCD inverter connector 2 x USB 2.0 ports, 1 x FDD port and 1 x RS232 serial port 1 x onboar d 5-pin AT keyboard port External I/O Port 1 x RJ45 LAN ports, 1 x DB15 VGA port and 1 x PS/2 Keyboard/ Mouse Port 1 x RS232 Serial Port Pow er Re quirement +5V , +12V DC inp ut Board Dimension 185 x 127 mm (L x W) Operation Temperatu r e 0 ~ 60 O C (32 ~ 140 O F) Ordering Code HS-870P Intel Pentiu m M Half-size PISA Bus CPU Card with onboard VGA, Gigabit LAN, USB 2.0 Ports, Audio, LVDS, RS232 serial port, Comp act Flash Socket Online product information detai l and updates are available at www. comm
Index TUChapter1 UT .................................................................................... 7 TU1.1 UT ................................................................................. 7 TU1.2 UT ........................................................................... 8 TU1.3 UT ...................................................................... 10 TU1.4 UT .................................................................................... 11 TUChapter 2 UT ............................................................................. 13 TU2.1 UT .......................................................................... 13 TU2.2 UT ............................................................................. 14 TU2.3 UT ....................................................................... 15 TU2.3.1 UT ................................................................ 15 TU2.3.2 UT................................................................. 15 TU2.4 UT ..................................................................................... 16 TU2.4.1 UT .............................................................................. 16 TU2.4.2 UT ............................................................ 17 TU2.4.3 UT ................................................................... 18 TU2.4.4 UT ........................................... 19 TU2.5 UT ...................................................................................... 20 TU2.6 UT ..................................................................... 21 TU2.7 UT ........................
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值