// Tyler Rigsby, CSE 142 // Contains several examples of String manipulations and tests import java.util.*; public class Login { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("Please enter your name (first last): "); String name = console.nextLine(); int spaceIndex = name.indexOf(" "); String firstName = name.substring(0, spaceIndex); // note the second index is exclusive System.out.print("Hello, " + firstName + ", please enter your password: "); String password = console.next(); String realPassword = "avacado"; if (password.equals(realPassword)) { System.out.println("Access granted. Welcome to the system."); if (name.endsWith("Obama")) { System.out.println("Welcome, President Obama. You just missed Edward Snowden!"); } } else { System.out.println("Permission denied!"); } } }