-
Lenguaje
Java usando Scanner
-
Descripción
Se tiene un recipiente cilíndrico de radio r y altura h y una caja de ancho a, largo b y altura c. Se desea saber cuál de ellos tiene mayor capacidad de almacenamiento.
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
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
import java.util.Scanner;
public class CapacidadDeUnRecipienteYUnaCaja {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double a, b, c, h, r;
double volumen_caja, volumen_recipiente;
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 h: ");
h = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de r: ");
r = in.nextDouble();
in.nextLine();
volumen_recipiente=Math.PI*r*r*h;
volumen_caja=a*b*c;
if(volumen_recipiente>volumen_caja)
System.out.println("El recipiente cil\u00EDndrico tiene mayor capacidad");
if(volumen_recipiente==volumen_caja)
System.out.println("Tienen la misma capacidad");
if(volumen_recipiente<volumen_caja)
System.out.println("La caja tiene mayor capacidad");
System.out.println("Valor de volumen caja: " + volumen_caja);
System.out.println("Valor de volumen recipiente: " + volumen_recipiente);
}
}
public class CapacidadDeUnRecipienteYUnaCaja {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double a, b, c, h, r;
double volumen_caja, volumen_recipiente;
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 h: ");
h = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de r: ");
r = in.nextDouble();
in.nextLine();
volumen_recipiente=Math.PI*r*r*h;
volumen_caja=a*b*c;
if(volumen_recipiente>volumen_caja)
System.out.println("El recipiente cil\u00EDndrico tiene mayor capacidad");
if(volumen_recipiente==volumen_caja)
System.out.println("Tienen la misma capacidad");
if(volumen_recipiente<volumen_caja)
System.out.println("La caja tiene mayor capacidad");
System.out.println("Valor de volumen caja: " + volumen_caja);
System.out.println("Valor de volumen recipiente: " + volumen_recipiente);
}
}