Header Ads

Header ADS

Solution of URI 1051::Taxes

Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problemyou will inform me by comment.




#include <stdio.h>
int main()
{
    double salary,taxes=0.0;

    scanf("%lf",&salary);

    if (salary<=2000.0) {
        printf("Isento\n");
        return 0;
    }

    else if (salary>=2000.01 && salary<=3000.0 ) {
            salary = salary - 2000.0;
            taxes= (0.08*salary);
    }

    else if (salary>=3000.01 && salary<=4500.0 ) {
            salary = salary - 3000.0;
            taxes= (0.08*1000.0) + (0.18*salary);
    }

    else if ( salary>4500.0 ) {
            salary = salary - 4500.0;
            taxes= (0.08*1000.0) + (0.18*1500.0) + (0.28*salary);
    }


        printf("R$ %.2lf\n",taxes);


   r
eturn
 0;
}

No comments

Theme images by konradlew. Powered by Blogger.