View Code of Problem 70

#include<stdio.h>
#include<math.h>
main()
{
	float a,b,c,d,g,l;
	int w,n;
	a=100000*0.1;
	b=a+100000*0.075;
	c=b+200000*0.05;
	d=c+200000*0.03;
	g=d+400000*0.015;
    scanf("%d",&n);
    w=n/100000;
    switch(w)
    {
    	case 0:l=n*0.1;break;
    	case 1:l=a+(n-100000)*0.075;break;
    	case 2:
    	case 3:l=b+(n-200000)*0.05;break;
    	case 4:
    	case 5:l=c+(n-400000)*0.03;break;
    	case 6:
    	case 7:
    	case 8:
    	case 9:l=d+(n-600000)*0.015;break;
    	case 10:l=g+(n-1000000)*0.01;break;
	}
	printf("%.0f",l);
}

Double click to view unformatted code.


Back to problem 70