// A simple but very insecure login system in which // everyone has the same password. // // Notice the use of String methods, especially .equals.import java.util.*; public class LoginSystem { public static final String REAL_PASSWORD = "CSE142_Rocks!"; public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("Enter your full name: "); String name = console.nextLine(); int spaceIndex = name.indexOf(" "); String firstName = name.substring(0, spaceIndex); System.out.println("Welcome, " + firstName + "!"); System.out.print("Enter your password: "); String pass = console.nextLine(); while (!REAL_PASSWORD.equalsIgnoreCase(pass)) { System.out.println("WRONG! Try again..."); System.out.print("Enter your password: "); pass = console.nextLine(); } System.out.println("Correct. Logging in..."); } }