Create a method (changePW) that, given a new password as an input parameter, che
ID: 3621563 • Letter: C
Question
Create a method (changePW) that, given a new password as an input parameter, checks to make sure it does not match any other previous passwords in the pwds array.
1. If it does not match, it saves the new password in the next available spot in the pwds array, updates the current password position variable (currentPW), and returns an integer value of 0 to indicate success.
2. If the array is already full, the oldest password (in index position [0]) should be discarded by shifting the values of all of the rest of the positions in the array up by 1. This will make the last position available again to save the new password.
3. If the new password does match one already in the array, the password is not saved in the array and the method returns an integer value of -1 to indicate that the password change attempt failed.
This is what I have so far. I think I have part 3 figured out, but I can't figure out how to go about the rest of this.
Explanation / Answer
Here's what you would have to add in order to get parts 1 and 2 in as well. Let me know if you have any questions. Hope this helps. Please rate. :) public static int changePW( String password) { int changeNum = 0; for (int i = 0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.