TOPIC

Wrong aswer(5%)

PatrickLuz asked 2 years ago

Eu realmente não consigo achar o erro, poderiam me ajudar ?

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

public class Main {

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

        float n;
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextFloat();

        if (n <= 2000) {
            System.out.print("Isento\n");
        } else if (n >= 2000.01 && n <= 3000.00) {
            float result = (n * 8) / 100;
            System.out.printf("R$ %.2f\n", result);

        } else if (n >= 3000.01 && n <= 4500) {
            float temp1 = n - 3000;
            float temp2 = n - (2000 + temp1);
            float result = ((temp2 * 8) / 100) + ((temp1 * 18) / 100);
            System.out.printf("R$ %.2f\n", result);
        } else if (n > 4500) {
            float temp1 = n - 4500;
            float temp2 = n - (temp1 + 3000);
            float temp3 = n - (temp1+temp2+2000);
            float a = temp1 * 28 / 100;
            float b = temp2 * 18 / 100;
            float c = temp3 * 8 / 100;
            float result = a + b + c;
            System.out.printf("R$ %.2f\n", result);
        }
    }

}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.