Question: Passwords C++ . Write a program that will allow a user to enter their username and password, and then validate the combination. This requires you

Passwords C++

. Write a program that will allow a user to enter their username and password, and then validate the combination. This requires you to first verify the input username exists in the array, then validate the input password. Do this as follows:

Read the user names and passwords into two arrays (you should have one array of user names and a parallel array of passwords). Define a function to handle reading the data into the arrays.

Copy and paste your sort function from Task 1. Modify sort so that whenever a name is swapped, the corresponding password is moved with it (i.e., the names get sorted, but the passwords have to be kept consistent as the names are sorted). Note that you will have to pass both arrays to the sort function.

Define a function binarySearch that will search the array of usernames. The function should return the location of the username or a -1 if not found. The array of usernames and the username were searching for should be passed as parameters to the function. Refer to the example binarySearch function in your book.

In main(), call the function to load the file data into arrays, then call the function to sort the data. Next, ask the user for a name and a password. The program should use binarySearch to search for the username that was entered. Once you know the location of the username, you can use that index to compare the associated password with the username that was entered. If the passwords match, the program should output Youre logged in!. If the passwords dont match, the program should say Sorry, invalid password. If the username isnt found in the list of usernames, the program should say invalid username.

[1] In real life, passwords wouldnt be stored in clear text; they would be encrypted.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!