-
Lenguaje
Java usando Scanner
-
Descripción
Lea 4 variables numéricas y calcule e imprima la suma, su media aritmética y producto.
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
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
import java.util.Scanner;
public class SumaMediaAritmeticaYProductoDe4Numeros {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double a, b, c, d, media;
double producto, suma;
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();
suma=a+b+c+d;
media=suma/4;
producto=a*b*c*d;
System.out.println("Valor de media: " + media);
System.out.println("Valor de producto: " + producto);
System.out.println("Valor de suma: " + suma);
}
}
public class SumaMediaAritmeticaYProductoDe4Numeros {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double a, b, c, d, media;
double producto, suma;
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();
suma=a+b+c+d;
media=suma/4;
producto=a*b*c*d;
System.out.println("Valor de media: " + media);
System.out.println("Valor de producto: " + producto);
System.out.println("Valor de suma: " + suma);
}
}