Saturday, April 30, 2016

URI Online Judge Solution 1051 in Java || Taxes


URI Online Judge | 1051

Taxes

By Neilor Tonin, URI  Brazil
Timelimit: 1
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 SamplesOutputs Samples
3002.00R$ 80.36
1701.12Isento
4520.00R$ 355.60

URI Online Judge Solution 1051 in Java || Taxes


import java.io.IOException;
import java.util.Scanner;

/**
 * IMPORTANT: 
 *      O nome da classe deve ser "Main" para que a sua solução execute
 *      Class name must be "Main" for your solution to execute
 *      El nombre de la clase debe ser "Main" para que su solución ejecutar
 */
public class Main {

    public static void main(String[] args) throws IOException {

        float n, r, f1, f2, f3;
Scanner sc =new Scanner(System.in);
n = sc.nextFloat();

if(n <= 2000){
System.out.print("Isento\n");
}else{
if(n > 2000 && n <= 3000){
f1 = n - 2000;
f1 = ((f1 * 8) / 100);
r = f1;
}else if(n > 3000 && n <= 4500){
f1 = n - 2000;
f2 = f1 - 1000;
f1 -= f2;
f1 = ((f1 * 8) / 100);
f2 = ((f2 * 18) / 100);
r = f2 + f1;
}else{
f1 = n - 2000;
f2 = f1 - 1000;
f3 = f2 - 1500;
f1 -= f2;
f2 -= f3;
f1 = ((f1 * 8) / 100);
f2 = ((f2 * 18) / 100);
f3 = ((f3 * 28) / 100);
r = f3 + f2 + f1;
}
System.out.printf("R$ %.2f\n",r);
}

    }

}



No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.