// An example of using several String methods. This is a weak login // system that will print out a special message given the correct password // // This new version will continue to prompt the user until the correct // password is entered. import java.util.*; public class LoginSystem { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("What is your full name? "); String name = console.nextLine(); String firstName = name.substring(0, name.indexOf(" ")); String realPassword = "jgrasp123"; System.out.print("Hello, " + firstName + " what is your password? "); String password = console.nextLine(); while (!password.equals(realPassword)) { System.out.println("Imposter! Want to try again?"); System.out.print("Hello, " + firstName + " what is your password? "); password = console.nextLine(); } System.out.println("Welcome!"); } }