• Lenguaje

    Java usando Scanner

  • Descripción

    Permite leer 3 valores diferentes e indica cuáles de ellos son iguales o si todos son 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
import java.util.Scanner;

public class IgualdadDe3Valores {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double a, b, c;
        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();
        if(a==b&&b==c)
            System.out.println("Todos son iguales.");
        if(a==b&&b!=c)
            System.out.println("A y B son iguales.");
        if(a==c&&b!=c)
            System.out.println("A y C son iguales.");
        if(b==c&&a!=c)
            System.out.println("B y C son iguales.");
    }

}