Tan Haoqiang's edition of "C Program Design" (second edition) P105 5.8 bonuses awarded by enterprises according to profit Commission (switch) _c

Source: Internet
Author: User

Tan Haoqiang's edition of "C Program Design" (second edition) P105 5.8 bonuses awarded by enterprises are based on profit percentage.

Profit I is less than or equal to 100,000 yuan, bonuses can be 10%;200000<i<=400000, below 200,000 far lower part of the above method of Commission (hereinafter). More than 200,000 yuan of the part of 5% commission; When 400000<i<=600000, more than 400,000 yuan of the part by 3% commission; When 600000<i<=1000000, higher than 600,000 yuan part by 1.5% Commission; I>1000000, More than 1 million yuan of the part by 1% Commission. Enter the monthly profit from the keyboard I, the total number of bonuses should be issued.

#include <stdio.h>
int main ()
{
	float i,jj,jj10w,jj20w,jj40w,jj60w,jj100w;
	printf ("Please enter profit:");
	scanf ("%f", &i);
	Fflush (stdin);
	jj10w=100000*0.1;
	jj20w=jj10w+100000*0.075;
	jj40w=jj20w+200000*0.05;
	jj60w=jj40w+200000*0.03;
	jj100w=jj60w+400000*0.015;
	int DANGCI;
	dangci=i/100000;
	Switch (DANGCI)
	{case
		0:jj=i*0.01;break;
		Case 1:jj=jj10w+ (I-100000) *0.075;break;
		Case 2: Case
		3:jj=jj20w+ (I-200000) *0.05;break;
		Case 4: Case
		5: Case
		6:jj=jj40w+ (I-400000) *0.03;break;
		Case 7: Case
		8: Case
		9:jj=jj60w+ (I-600000) *0.015;break;
		Case 10:jj=jj100w+ (I-1000000) *0.001;break;
	}
	printf ("Bonus:%.2f\n", JJ);
	return 0;
}
is much clearer than if statement version.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.