import java.util.Scanner;
import java.text.NumberFormat;
import java.util.Locale;
public class Entrega {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Digite a distância em km: ");
        String distStr = sc.nextLine().trim().replace(',', '.'); 
        double distancia;
        try {
            distancia = Double.parseDouble(distStr);
            if (distancia < 0) {
                System.out.println("Distância inválida. Deve ser maior ou igual a 0.");
                sc.close();
                return;
            }
        } catch (NumberFormatException e) {
            System.out.println("Entrada inválida para distância.");
            sc.close();
            return;
        }
        System.out.print("Está chovendo? (s/n): ");
        String chuvaStr = sc.nextLine().trim().toLowerCase();
        boolean chovendo = chuvaStr.startsWith("s"); 
        double taxa = calcularTaxa(distancia, chovendo);
        NumberFormat nf = NumberFormat.getCurrencyInstance(new Locale("pt", "BR"));
        System.out.println("Taxa final: " + nf.format(taxa));
        sc.close();
    }
    // lógica separada para facilitar testes/uso futuro
    public static double calcularTaxa(double distanciaKm, boolean chovendo) {
        double base;
        if (distanciaKm <= 5) {
            base = 5.0;
        } else if (distanciaKm <= 10) {
            base = 8.0;
        } else {
            base = 10.0;
        }
        if (chovendo) {
            base += 2.0;
        }
        return base;
    }
}