Hello, we were assigned to make a program that will check username and password with 3 attempts using a text file, hashmap, io, and exceptions. The thing is I do not know how to start it because I do not understand the topic about hashmap. I hope you guys can help
It's hard to know where to begin with helping because it's unclear how far you've gotten with it. Perhaps you can show us what you've got so far and what specific problem you are facing?
You do realise that storing a password is very insecure and nobody does that in reeal life. You also realise that we won't give you a full answer but will help you if you are allowed to show us the code posing you problems. I suggest you find out about maps in the Java™ Tutorials. You may wish to concentrate on the two sections in that link about Maps.
neo zef wrote:... I do not know how to start it because I do not understand the topic about hashmap...
You could start by telling us how you were planning to use the text file, how you were going to handle the exceptions and what exactly is unclear to you about HashMap. In a nutshell, it's just a key value pair data structure.
even without knowing much about hashmaps, there's a lot you could do. you know you'll need to ask for a user name, ask for a password, read <something> from a file, and you need a loop that does something three times. Try and do one piece at a time, get it to work, then add in another piece. Then show us what you have, and tell us specifically where you are stuck.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Sorry I dont know if this will be under the replies, this is my first time using Ranch. I already have a text file which is just a simple "user1 pass1" up to 4. I think Ive already made a progress on the boolean part, I just do not know how to make it compatible with a text file or how to even use a text file and a hashmap. currently a first year info system who's pretty bad at programming
Please quote the code as text with the code button because screenshots are much more difficult to copy. Also, some people find multicoloured text hard to read. Don't create new Scanners to read System.in. You never need more than one Scanner to read System.in.