URI Online Judge Solution 1051 Taxes using C Programming Language.
In an imaginary country called Lisarb, all the people are very happy to pay their taxes because they know that doesn’t exist corrupt politicians and the taxes are used to benefit the population, without any misappropriation. The currency of this country is Rombus, whose symbol is R$.
Read a value with 2 digits after the decimal point, equivalent to the salary of a Lisarb inhabitant. Then print the due value that this person must pay of taxes, according to the table below.
Remember, if the salary is R$ 3,002.00 for example, the rate of 8% is only over R$ 1,000.00, because the salary from R$ 0.00 to R$ 2,000.00 is tax free. In the follow example, the total rate is 8% over R$ 1000.00 + 18% over R$ 2.00, resulting in R$ 80.36 at all. The answer must be printed with 2 digits after the decimal point.
Input
The input contains only a float-point number, with 2 digits after the decimal point.
Output
Print the message "R$" followed by a blank space and the total tax to be payed, with two digits after the decimal point. If the value is up to 2000, print the message "Isento".
Input Samples | Outputs Samples |
3002.00
|
R$ 80.36
|
1701.12
|
Isento
|
4520.00
|
R$ 355.60
|
Solution using C :
#include <stdio.h>
int main() {
float sal;
scanf("%f",&sal);
if(sal>0 && sal<=2000.00)
{
printf("Isento\n");
}
else if(sal>=2000.01 && sal<=3000.00)
{
sal = ((sal - 2000.00)*8)/100;
printf("R$ %.2f\n",sal);
}
else if(sal>=3000.01 && sal<=4500.00)
{
sal = sal - 2000.00;
sal = (((sal-1000.00)*18)/100) + ((1000*8)/100);
printf("R$ %.2f\n",sal);
}
else if(sal>4500.00)
{
sal = sal - 2000.00;
sal = (((sal-2500.00)*28)/100) + ((1500*18)/100)+((1000*8)/100);
printf("R$ %.2f\n",sal);
}
return 0;
}
Comments
Post a Comment