Question
IN JAVA Create a program that allows the user to create accounts. For each new account, ask the user to enter a username and password
IN JAVA
Create a program that allows the user to create accounts. For each new account, ask the user to enter a username and password separately. Save the account information to a text file, called "accounts.txt". When adding to the text file, each account should be on a separate line with a space between username and password. After each account has been entered, the user should be asked whether or not they want to enter another one. If they choose to quit, display "Goodbye."
Part 2:
In the second part, read in the account information from "accounts.txt". Create two ArrayLists - one for the usernames and one for the passwords. For each line read in from the text file, add the username and password into their respective ArrayLists.
Notice that since each username and password is added at the same rate, the index value should always match. For example, the first account should have the username at index of 0 in one ArrayList, and the password at index of 0 in the second ArrayList. The second account should have username at index 1 and password at index 1. And so on...
Once all of the information from "accounts.txt" has been successfully added to the ArrayLists, don't forget to close the Scanner we used to read the text file!
Next, ask the user to login by entering a username. Check to see if that username is in the corresponding ArrayList. If so, ask them to enter a password and check to see if they entered the correct password. If not, display a message "That account does not exist."
If the user logged in successfully, simply display "Success!".
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started