• Lenguaje

    Java usando Scanner

  • Descripción

    Ingrese seis notas y calcule el promedio, considerando las 5 mejores notas.

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.Scanner;

public class PromedioDeLas5MejoresNotas {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double nota_1, nota_2, nota_3, nota_4, nota_5;
        double nota_6, nota_menor, 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();
        System.out.print("Ingresa el valor de nota 5: ");
        nota_5 = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de nota 6: ");
        nota_6 = in.nextDouble();
        in.nextLine();
        if(nota_menor>nota_2)
            nota_menor=nota_2;
        if(nota_menor>nota_3)
            nota_menor=nota_3;
        if(nota_menor>nota_4)
            nota_menor=nota_4;
        if(nota_menor>nota_5)
            nota_menor=nota_5;
        if(nota_menor>nota_6)
            nota_menor=nota_6;
        promedio=(nota_1+nota_2+nota_3+nota_4+nota_5+nota_6-nota_menor)/6;
        System.out.println("Valor de nota menor: " + nota_menor);
        System.out.println("Valor de promedio: " + promedio);
    }

}