64 630
Assignments Done
99,1%
Successfully Done
In September 2018

Answer to Question #58180 in C++ for shantanu more

Question #58180
how to make login page in cpp file handling with following requirements:

1)create new account(create username and password)
2) Login
3)quit
Expert's answer
#include <iostream>
#include <map>
using namespace std;


int main() {
map<string, string> list;
int choise;
string username, password;

while (true) {
cout << "1. Create new account\n"
"2. Login\n"
"0. Quit\n";
cin >> choise;

switch(choise) {
case 1:
cout << "\tEnter username: ";
cin >> username;
cout << "\tEnter password: ";
cin.get();
getline(cin, password);
list[username] = password;
cout << "\t User added\n";
break;
case 2:
cout << "\tEnter username: ";
cin >> username;
cout << "\tEnter password: ";
cin.get();
getline(cin, password);
if (list[username] == password)
cout << "\t Hello, " << username << endl;
else
cout << "\t Incorrect username or password!" << endl;
break;
case 0:
cout << "Good bye!" << endl;
return 0;
default:
cout << "Wrong input" << endl;
}
}

return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions