[Arrays]D. Liang 6.13 Finding the sales amount

Description

You have started a sales job in a department store.
Your pay consists of a basis salary and a commission. The base salary is $5000.
The scheme shown below is used to determine the commission rate.

Sales Amount		Commission Rate
---------------------------------------
$0.01-$5000		     8 percent
$5000-$10000		   10 percent
$10000.01 and above	12 percent

Your goal is to earn $na year. Write a program that finds out the minimum amount
of sales you have to generate in order to make $n.

Input

The first line is a positive integer t for the number of test cases.

Each test case contains an double value n (0<n<=1000000).

Output

For each test case, outputs the minimum amount of sales you have to generate in order to make $n.

You should specified the floating-point number’s precision to 0 and fixed.

Sample Input

2
30000
60000

Sample Output

210833
460833

Problem Source: 程序设计I Chapter6 Arrays

//   Date:2020/4/24
//   Author:xiezhg5
#include <stdio.h>
#include <stdlib.h>
//注意数据类型 
double Fun(double price) {
	double p_rice=price-5000;    //减去5000元的基本工资 
	double sum = 0.0;
	//用除法得到原来的数值
	//注意分段 
	if(p_rice< 5000*0.08)
		sum += (p_rice-5000)/0.08;
	else if( p_rice>= 5000*0.08 && p_rice <= 5000*0.08 + 5000*0.10) {
		sum += 5000;
		sum += (p_rice-5000*0.08)/0.10;
	} else {
		sum = sum + 5000;
		sum = sum + 5000;
		sum = sum + (p_rice - 400 - 500)/0.12;
	}
	return sum;
}
int main(void) {
	int n = 0;
	double price[100] = {0.0};
	scanf("%d",&n);
	for(int i = 0; i < n; i++)
		scanf("%lf",&price[i]);
	for(int i = 0; i < n; i++)
		price[i] = Fun(price[i]);  //将最终得到的薪水传入Fun函数中 
	for(int i = 0; i < n; i++)
		printf("%.0lf\n",(double)price[i]);
	return 0;
}
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值