Advertisement
GreMendes

Verificador de senha - JAVA

Aug 17th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. package br.pucpr.bsi;
  2. import java.util.Scanner;
  3.  
  4. public class Exxx {
  5.  
  6.     private static boolean verificaSenha(int[] pwD, int[] pwC){
  7.        
  8.        
  9.        
  10.         for(int i = 0; i < 3; i++){
  11.             if(pwD[i] != pwC[i]){
  12.                 return false;
  13.             }
  14.            
  15.         }
  16.        
  17.         return true;
  18.                    
  19.                
  20.     }
  21.    
  22.     @SuppressWarnings("resource")
  23.     private static int[] recolheSenha(int[] passDig){
  24.  
  25.         Scanner sc;
  26.         sc = new Scanner(System.in);
  27.  
  28.         System.out.println("Digite o primeiro numero: ");
  29.         passDig[0] = sc.nextInt();
  30.         System.out.println("Digite o segundo numero: ");
  31.         passDig[1] = sc.nextInt();
  32.         System.out.println("Digite o terceiro numero: ");
  33.         passDig[2] = sc.nextInt();
  34.         System.out.println("Digite o quarto numero: ");
  35.         passDig[3] = sc.nextInt();
  36.        
  37.         return passDig;
  38.     }
  39.    
  40.    
  41.     public static void main(String[] args) {
  42.        
  43.         int [] password, passDig;
  44.        
  45.         password = new int[4];
  46.        
  47.         passDig = new int[4];
  48.         System.out.println("Senha digitada: " + passDig);
  49.        
  50.         for(int i = 0; i < 3; i++)
  51.             password[i] = i;
  52.        
  53.         passDig = recolheSenha(passDig);
  54.        
  55.         if(verificaSenha(passDig, password) == true){
  56.             System.out.println("Senha Correta!");
  57.         }else{
  58.             System.out.println("Senha invalida - Tente Novamente");
  59.             passDig = recolheSenha(passDig);
  60.             verificaSenha(passDig, password);
  61.            
  62.         }
  63.        
  64.  
  65.     }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement