• Lenguaje

    Java usando Scanner

  • Descripción

    Leer dos números enteros positivos y determinar si el último dígito de un número es igual al último dígito del otro.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.util.Scanner;

public class IgualdadDeLosUltimosDigitos {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a, b;
        System.out.print("Ingresa el valor de a: ");
        a = in.nextInt();
        in.nextLine();
        System.out.print("Ingresa el valor de b: ");
        b = in.nextInt();
        in.nextLine();
        if(a%10==b%10)
            System.out.println("Los \u00FAltimos d\u00EDgitos son iguales.");
        else
            System.out.println("Los \u00FAltimos d\u00EDgitos son diferentes.");
    }

}