博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UT源码+105032014018
阅读量:6709 次
发布时间:2019-06-25

本文共 1850 字,大约阅读时间需要 6 分钟。

  设计佣金问题的程序

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

你可能感兴趣的文章
货币的起源和职能是什么?绘制货币资金管理思维导图简单的方法介绍
查看>>
springboot+kafka+elk+docker+docker-compose+centos搭建日志收集系统
查看>>
时讯无线如何满足商业区的无线覆盖?
查看>>
2014最新open***搭建实例
查看>>
WinAPI: midiOutCachePatches - 预装音色
查看>>
finally执行顺序
查看>>
TWebBrowser 与 MSHTML(2): 获取 window 对象的时机
查看>>
【博客话题】IT人,你肿么了? ——除了IT,你还能选择什么?
查看>>
docker初步入门
查看>>
Outlook提示:无法安装或装载加载项vpmsece.dll
查看>>
使用Apache开源POI和jXLS两种API生成报表
查看>>
oracle控制台OEM无法启动
查看>>
haproxy负载均衡
查看>>
clink 让cmd像ubuntu gnome-terminal一样
查看>>
初识Java模板引擎Beetl之简单示例
查看>>
Oracle UNDO表空间的管理
查看>>
canal.deployer-1.1.0版本,当监听到数据库变动时,server端报异常,docker单核引起的问题...
查看>>
JAVA并发编程:干掉 Synchronized
查看>>
JAVA .class 文件防止反编译
查看>>
iOS-<UITabBarControllerDelegate> 代理不执行
查看>>