how can I make it accept decimals in my divition

-1

everything works fine but when I enter a decimal code does not work how can I make it work?

    System.out.println("¿Cual es tu nombre?");
    String edaparcialdd = sc.nextLine();
    System.out.println("Bienvenido de nuevo " + edaparcialdd);

    System.out.print("Introduce la Cal. del parcial 1\n");
    double num1 = sc.nextDouble();

    System.out.print("Introduce la Cal. del parcial 2\n");
    double num2 = sc.nextDouble();

    System.out.print("Introduce la Cal. del parcial 3\n");
    double num3 = sc.nextDouble();

    double sum = num1 + num2 + num3;
    double div = sum / 3;

    if (div >= 6) {
        System.out.println("El Alumno " + edaparcialdd);
        System.out.println("FUE APROBADO CON: " + div);
    } else {
        System.out.println("El Alumno " + edaparcialdd );
        System.out.println("NO FUE APROBADO CON: " + div);
    }

}}
    
asked by Vicente NT 15.04.2018 в 05:58
source

1 answer

0

When using sc.nextDouble () by default you have to use the comma (,) to separate the whole part of the decimal, that is, put "7.5" and not "7.5"

    
answered by 15.04.2018 / 22:23
source