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)){ System.out.println("Fallaste jaja!! "); input = sc.nextLine(); } else{ System.out.println("Correcto!"); return; } } System.out.println("Fallaste jaja!! "); } public static boolean es_correcto(String contraseña, String input){ if(contraseña.compareTo(input) == 0){ return true; } return false; } }