Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int soma = 0;
- int resto = 0;
- int i;
- int j = 10;
- if (cpf == "00000000000") {
- System.out.println("Fake News.");
- this.cpf = "EAE";
- return;
- }
- for (i = 0; i < 9; i++){
- soma = soma + ((cpf.charAt(i) - 48) * j);
- j = j - 1;
- }
- resto = (soma * 10) % 11;
- if (resto == 10 || resto == 1) {
- resto = 0;
- }
- if (resto == (cpf.charAt(9) - 48)) {
- soma = 0;
- j = 11;
- for (i = 0; i < 10; i++){
- soma = soma + ((cpf.charAt(i) - 48) * j);
- j = j - 1;
- }
- resto = (soma * 10) % 11;
- if (resto == (cpf.charAt(10) - 48)) {
- this.cpf = cpf;
- }
- }else{
- this.cpf = "2345meia78";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement