*5.39 (Financial application: find the sales amount) You have just started a sales job in a department store. Your pay consists of a base salary and a commission. The base salary is $5,000. The scheme shown below is used to determine the commission rate. Your goal is to earn $30,000 a year. Write a program to find the minimum sales you have to generate in order to make $30,000.
Sales Amount
Commission Rate
$0.01~$5000
8%
$5000.01~10000
10%
$10000.01and above
12%
参考代码:
package chapter05;publicclassCode_39{publicstaticvoidmain(String[] args){finalint BASE_SALARY =5000;int salesAmount =10000;double mySalary =0;do{
mySalary = BASE_SALARY +5000*0.08+5000*0.10+(salesAmount-10000)*0.12;
salesAmount++;}while(mySalary <30000);
System.out.printf("The minimum sales you have to generate is %d", salesAmount);}}
结果显示:
The minimum sales you have to generate is 210835
Process finished with exit code 0