-
Lenguaje
Java usando Scanner
-
Descripción
Se ingresa 3 números diferentes y determine el número medio del conjunto de los tres números (el número medio es aquel número que no es ni mayor, ni menor).
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
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
import java.util.Scanner;
public class MedioDe3Numeros {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double a, b, c, medio;
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();
medio=0;
if(a>=b&&b>=c)
medio=b;
if(b>=c&&c>=a)
medio=c;
if(c>=a&&a>=b)
medio=a;
System.out.println("Valor de medio: " + medio);
}
}
public class MedioDe3Numeros {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double a, b, c, medio;
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();
medio=0;
if(a>=b&&b>=c)
medio=b;
if(b>=c&&c>=a)
medio=c;
if(c>=a&&a>=b)
medio=a;
System.out.println("Valor de medio: " + medio);
}
}