View Code of Problem 70

#include <stdio.h>

int fx(int x)
{
    if(x <= 100000)
        return 0.1 * x;
    else if(x > 100000 && x <= 200000)
        return 10000 + 0.075 * (x - 100000);
    else if(x > 200000 && x <= 400000)
        return 17500 + 0.05 * (x - 200000);
    else if(x > 400000 && x <= 600000)
        return 22500 + 0.03 * (x - 400000);
    else if(x > 600000 && x <= 1000000)
        return 24000 + 0.015 * (x - 600000);
    else
        return  28000 + 0.01 * (x - 1000000);

}
int main(void)
{
    int x;
    while(scanf("%d",&x) != EOF)
    {
        printf("%d\n",fx(x));
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 70