• Lenguaje

    Java usando Scanner

  • Descripción

    Calcular el mayor de 5 números, hacer proceso 10 veces.

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 MayorDe5Numeros10Veces {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int i;
        double a, b, c, d, e;
        double mayor;
        for (i=1; i<=10; i++) {
            System.out.print("PROCESO " + i);
            System.out.print("Ingresa el valor de a: ");
            a = in.nextDouble();
            in.nextLine();
            System.out.print("Ingresa el valor de b: ");
            b = in.nextDouble();
            in.nextLine();
            System.out.print("Ingresa el valor de c: ");
            c = in.nextDouble();
            in.nextLine();
            System.out.print("Ingresa el valor de d: ");
            d = in.nextDouble();
            in.nextLine();
            System.out.print("Ingresa el valor de e: ");
            e = in.nextDouble();
            in.nextLine();
            if(a>b)
                mayor=a;
            else
                mayor=b;
            if(mayor<c)
                mayor=c;
            if(mayor<d)
                mayor=d;
            if(mayor<e)
                mayor=e;
            System.out.println("Valor de mayor: " + mayor);
            System.out.println();
        }
    }

}