Question: ***** I need these algorithms converted to Java Algorithms for the Project. Part 1: Answer = y Open (unit =5, file =UMF.txt, status =append) *opening
***** I need these algorithms converted to Java
Algorithms for the Project. Part 1: Answer = y Open (unit =5, file =UMF.txt, status =append) *opening a file with append capabilities* While(answer == y or answer == Y) Print Enter username Read username Print Enter password Read Password HasedPassword = Hash(password) Print 5, username, HashedPassword, password Print Do you want to continue? (Y/N) Read Answer End while Close (5) **closing file UMF.txt** End of Algorithm for Part 1 Algorithm for Part 2: First we need to know how many records are in UMF file. Open (Unit 5, file=UMF.txt, status =read) *opening the file to find the number of records. See a smaple java code for this portion at the end of Part 2* lines = 0; while (5, EOF != null) lines = lines +1 end while close(5) Open (Unit 5, file=UMF.txt, status =read) *opening the file again to read data only* Print Enter username Read Username Print Enter password Read Password Hashedpassword = Hash(password) counter =0 attempts =0 While (5, EOF != null) Read 5, fusername, fhashedpassword **reading username and password from the file counter = counter +1 **counting the number of lines in the file If (username ==fusername && Hashedpassowrd ==fhashedpassword) then Print Access Granted Exit the program Else if (username == fusername && Hashedpassowrd !==fhashedpassword) then attempts = attempts +1 if (attempts < 3) then print Incorrect password, try again else print Your account is locked! You exceed the allowable number of incorrect attempts Exit the program Elseif (username!=fusername && attempts ==lines) Print Username not found. You do not have an account in this system Exit the program End if Close (5) End of Algorithm for Part 2 The following is a small java code for finding the number of records or lines in a text file. BufferedReader reader = new BufferedReader(new FileReader("UMF.txt")); int lines = 0; while (reader.readLine() != null) lines++; reader.close();
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
