• Lenguaje

    Java usando Scanner

  • Descripción

    Dadas las 4 notas obtenidas por un alumno, calcular e informar su promedio e informar una leyenda que indique si está aprobado o no. La condición de aprobación es obtener un promedio mayor o igual que 4.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.Scanner;

public class PromedioDe4Notas {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double nota_1, nota_2, nota_3, nota_4, promedio;
        System.out.print("Ingresa el valor de nota 1: ");
        nota_1 = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de nota 2: ");
        nota_2 = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de nota 3: ");
        nota_3 = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de nota 4: ");
        nota_4 = in.nextDouble();
        in.nextLine();
        promedio=(nota_1+nota_2+nota_3+nota_4)/4;
        if(promedio>=4)
            System.out.println("Aprobado");
        else
            System.out.println("Reprobado");
        System.out.println("Valor de promedio: " + promedio);
    }

}