Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please show all the steps as detail as possible.... I need help with this.... **

ID: 3825659 • Letter: P

Question

Please show all the steps as detail as possible.... I need help with this....

*****************************************************************

Need Help on C++ Programming. Can you show me and teach me how to make this programming.

*Make sure the programming is working and do not turn in a handwriting.

*Do not separate the file, use main.cpp that make me understand how to do this programming. Use "iostream"

*****************************************************************

Hash Assignment

In this assignment, you will consider the problem of organizing a collection of computer user-ids and passwords. Each time a user logs in to the system by entering his or her user-id and a secret password, the system must check the validity of this user-id and password to verify that this is a legitimate user.

Because this validation must be done many times each day, it is necessary to structure this information in such a way that it can be searched rapidly. Moreover, this must be a dynamic structure because new users are regularly added to the system and some users deleted from the system.

Upon execution of your program, it should first read the user-ids and passwords from a file and create a hash using the user-id as a key (assume unique user-ids for convenience). Note: Initially it will be empty.

Once the hash has been built, it should display the following menu:

(1) Add new user

(2) Delete user

(3) Verify user

(4) Print users

(5) Quit

Option (1) and (2) simply add/delete new/existing users.

When option (3) is selected, the user is supposed to enter a user-id and a password.

Then, you should search the tree and a print message like "Valid User" or "Invalid User".

When option (4) is selected, the users and their passwords should be printed out in alphabetical order.

Finally, when option (5) is selected, the elements of hash should be stored to a file and execution should be terminated.

Test all options.

Print out File.

Write your conclusions.

Include code.

Screen prints of successful execution.

Explanation / Answer

#include<iostream>
#include<map>
#include<set>
#include<fstream>
using namespace std;

int main()
{
map<string,string> users;
ifstream f("a.txt");
string username,password;
do
{
f>>username;
f>>password;
users[username]=password;
}
while(!f.eof());
f.close();
cout << "Map size: " << users.size() << endl;


int option;
while(1)
{
cout<<"(1) Add new user (2) Delete user (3) Verify user (4) Print users (5) Quit";
cin>>option;

if(option==1)
{
cout<<"ENter username and password ";
string u,p;
cin>>u>>p;
users[u]=p;
}
else if(option==2)
{
cout<<"Enter username to be deleted";
string u;
cin>>u;
if(users.find(u) != users.end())
{
users.erase(u);
}

}

else if(option==3)
{

cout<<"ENter username and password ";
string u,p;
cin>>u>>p;
if(users.find(u) != users.end())
{
if(users[u]==p)cout<<"Valid User ";
  
else cout<<"Invalid User";
}

}
else if(option==4)
{
for( map<string, string>::iterator ii=users.begin(); ii!=users.end(); ++ii)
{
cout << (*ii).first << ": " << (*ii).second << endl;
}
}

else if(option==5)
{
ofstream f("a.txt");
for( map<string, string>::iterator ii=users.begin(); ii!=users.end(); ++ii)
{
f<< (*ii).first << " " << (*ii).second << endl;
}
f.close();
break;
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote