I need to make a program that reads a positive integer N. After reading this number, the program should evaluate if there are repeated numbers in the number.
For example: on 234571 there are no repeated digits. another example: there are 7656 repeated digits.
It has to be done in java and if possible without using vector, my doubt is how to make this check because it can not type a number with equal digits, understood?
package lista01;
import java.util.Scanner;
public class Ex08 {
public static void main(String[] args) {
Scanner ler = new Scanner(System.in);
int num = 0, a, b, c, d, contarDigitos = 0;
System.out.println("Digite um numero de quatro digitos diferentes");
num = ler.nextInt();
contarDigitos = (int) (Math.log10(num) + 1);
if (contarDigitos == 4) {
d = num / 1000;
a = (num / 100) % 10;
b = (num % 100) / 10;
c = (num % 10) % 10;
System.out.println("Resultado:" + d + a + b + c);
} else {
System.out.println("O numero precisa ter 4 digitos execute novamente!");
}
}
}
I do not know how to check if these numbers are different