• Lenguaje

    Java usando Scanner

  • Descripción

    A partir de 3 cantidades que te dan debes calcular el área de un círculo tomando como radio la cantidad mayor si la intermedia es mayor o igual a 5 de lo contrario se toma la menor. No hay iguales.

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
43
44
45
import java.util.Scanner;

public class AreaDeUnCirculoAPartirDe3Cantidades {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double area, cantidad_1, cantidad_2, cantidad_3, intermedia;
        double mayor, menor, radio;
        System.out.print("Ingresa el valor de cantidad 1: ");
        cantidad_1 = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de cantidad 2: ");
        cantidad_2 = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de cantidad 3: ");
        cantidad_3 = in.nextDouble();
        in.nextLine();
        if(cantidad_1>cantidad_2)
        {
            mayor=cantidad_1;
            menor=cantidad_2;
        }
        else
        {
            mayor=cantidad_2;
            menor=cantidad_1;
        }
        if(mayor<cantidad_3)
            mayor=cantidad_3;
        if(menor>cantidad_3)
            menor=cantidad_3;
        intermedia=(cantidad_1+cantidad_2+cantidad_3)/3;
        if(intermedia>=5)
            radio=mayor;
        else
            radio=menor;
        area=Math.PI*radio*radio;
        System.out.println("Valor de area: " + area);
        System.out.println("Valor de intermedia: " + intermedia);
        System.out.println("Valor de mayor: " + mayor);
        System.out.println("Valor de menor: " + menor);
        System.out.println("Valor de radio: " + radio);
    }

}