Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. main()
  5. {
  6. int code;
  7. string username, password;
  8. do
  9. {
  10. //Main Menu
  11. system("cls");
  12. cout << "--Main Menu--" << endl;
  13. cout << "[1]Login" << endl;
  14. cout << "[2]Exit" << endl;
  15.  
  16. cout << "\n\nEnter choice: ";
  17. cin >> code;
  18.  
  19. if(code == 1)
  20. {
  21. system("cls");
  22. cout << "--Login Menu--";
  23. cout << "\n\nEnter username: ";
  24. cin.ignore();
  25. getline(cin, username);
  26. cout << "Enter password: ";
  27. getline(cin, password);
  28.  
  29. if(username == "user" && password == "pass")//validation
  30. {
  31. cout << "Login successfully." << endl;
  32. system("pause");
  33. do
  34. {
  35. system("cls");
  36. cout << "You are so handsome!" << endl;
  37. cout << "Do you want to logout? Press 1: ";
  38. cin >> code;
  39. if(code == 1)
  40. {
  41. }
  42. else//0 below, 2 above
  43. {
  44. cout << "Invalid response." << endl << endl;
  45. system("pause");
  46. system("cls");
  47. }
  48. }
  49. while(code != 1);//
  50. }
  51. else
  52. {
  53. cout << "Invalid username/password." << endl;
  54. }
  55. system("pause");
  56. }
  57. else if(code == 2)//Exit
  58. {
  59. cout << "Thank you for using! Exiting...";
  60. }
  61. else//3 above, 0 below
  62. {
  63. cout << "Invalid choice." << endl << endl;
  64. system("pause");
  65. }
  66. }
  67. while(code != 2);//1
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement