Assignment 11 Due Friday, May 22 at 11:59pm on Canvas
Pair Programming Required (or You Will Receive a 0)
Assignment 11: New Password (10 pts)
Enter your new password: abc123 Enter your new password again: abc124 Sorry! Those passwords don't match. Please try again Enter your new password again: abc123 Password confirmed. Logging out...
Enter your new password: abc123 Enter your new password again: abc124 Sorry! Those passwords don't match. Please try again Enter your new password again: abc124 Sorry! Those passwords don't match. Goodbye!
Enter your new password: abc123 Enter your new password again: abc123 Password confirmed. Logging out... Enter your password:
Password confirmed. Logging out... Enter your password: abc124 Invalid password. You have 5 more tries. Enter your password: abc125 Invalid password. You have 4 more tries. Enter your password: abc123 Welcome! You are now logged in.
Password confirmed. Logging out... Enter your password: ab Invalid password. You have 4 more tries. Enter your password: abc Invalid password. You have 3 more tries. Enter your password: ab3 Invalid password. You have 2 more tries. Enter your password: abc1 Invalid password. You have 1 more tries. Enter your password: abc12 Invalid password. You have 0 more tries. Goodbye! /** * @author * @author * CIS 36A */ import java.util.Scanner; public class NewPasswords { public static void main(String[] args) { Scanner input = new Scanner(System.in); String password; String passwordConfirm; final int MAX_TRIES = 5; System.out.print("Enter your new password: "); password = input.next(); //fill in here if (//fill in test condition here){ System.out.println("\nSorry! Those passwords don't match.\nPlease try again"); //fill in here } if (password.equals(passwordConfirm)) { System.out.println("\nPassword confirmed. Logging out...\n"); for (//fill in here... hint count DOWN) { System.out.print("Enter your password: "); //fill in here if (//fill in here)) { System.out.println("\nWelcome! You are now logged in."); i = 0; //What does this line do? Make sure you understand } else { System.out.print("Invalid password.); //fill in here } } } else { System.out.print("Sorry! Those passwords don't match."); } System.out.println("\nGoodbye!"); input.close(); } }
Sample Output: Enter your new password again: abc123 Password confirmed. Logging out... Enter your password: abc123 Welcome! You are now logged in. Goodbye! Sample Output: Enter your new password: abc123 Enter your new password again: abc124 Sorry! Those passwords don't match. Please try again Enter your new password again: abc123 Password confirmed. Logging out... Enter your password: abc124 Invalid password. You have 4 more tries. Enter your password: abc1265 Invalid password. You have 3 more tries. Enter your password: abc124 Invalid password. You have 2 more tries. Enter your password: abc12 Invalid password. You have 1 more tries. Enter your password: abc123 Welcome! You are now logged in. Goodbye! Sample Output: Enter your new password: abc123 Enter your new password again: abc124 Sorry! Those passwords don't match. Please try again Enter your new password again: abc124 Sorry! Those passwords don't match. Goodbye! Sample Output: Enter your new password: abc123 Enter your new password again: abc123 Password confirmed. Logging out... Enter your password: abc124 Invalid password. You have 4 more tries. Enter your password: abc125 Invalid password. You have 3 more tries. Enter your password: abc Invalid password. You have 2 more tries. Enter your password: abc1 Invalid password. You have 1 more tries. Enter your password: abc12 Invalid password. You have 0 more tries. Goodbye! |