Ejercicio09.java 1.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author user
 */
public class Ejercicio09 {
    public static void main(String[] args) {
        String contraseña = new String("luque");
        Scanner sc = new Scanner(System.in);        
        
        System.out.print("Introduzca una contraseña: ");
        String input = sc.nextLine();
        //System.out.println("");        
        
        for(int i=0; i<2; i++){
            if(!es_correcto(contraseña, input)){
25
               System.out.println("Fallaste jaja!! ");
26 27 28 29 30 31 32
                input = sc.nextLine();                
            }
            else{
                System.out.println("Correcto!");
                return;
            }           
        }
33 34

        System.out.println("Fallaste jaja!! ");       
35 36 37 38 39 40 41 42 43 44 45
        
    }
    
    public static boolean es_correcto(String contraseña, String input){
        if(contraseña.compareTo(input) == 0){
            return true;
        }       
        return false;       
    }
    
}