Advertisement
Guest User

Untitled

a guest
Nov 17th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. //#include<iostream>
  2. //#include<cmath>
  3. //#include<iomanip>
  4. //#include<string>
  5. //#include<fstream>
  6. //#include<sstream>
  7. //#include<cstdlib>
  8. //
  9. //using namespace std;
  10. //
  11. //int main()
  12. //{
  13. // const int SIZE = 24;
  14. // string quizArray[SIZE];
  15. // ifstream dataFile;
  16. // string question2;
  17. //
  18. // dataFile.open("QuestionBank.txt");
  19. //
  20. // if (!dataFile)
  21. // cout << "Error opening data file\n";
  22. // else
  23. // {
  24. // for (getline(dataFile, line))
  25. // {
  26. //
  27. // dataFile >> quizArray[i];
  28. //
  29. // }
  30. // /*dataFile.close();*/
  31. //
  32. //
  33. //
  34. //
  35. //
  36. // getline(dataFile, question2);
  37. //
  38. // dataFile.close();
  39. //
  40. // cout << question2;
  41. // }
  42. //
  43. // system("pause");
  44. // return 0;
  45. // }
  46.  
  47.  
  48. #include <iostream>
  49. #include <fstream>
  50. #include <string>
  51. #include <vector>
  52. using namespace std;
  53.  
  54. int main()
  55. {
  56. char userSelect;
  57. string questons;
  58. ifstream dataFile;
  59. int a = 0;
  60. string previousLine = "";
  61.  
  62. string teacherUser, studentUser;
  63. string teacherPassword, studentPassword;
  64. int loginAttempt = 0;
  65. vector <int> v;
  66.  
  67. cout << "Welcome to Quiz Program \n";
  68. cout << "------------------------\n";
  69. cout << endl;
  70.  
  71. cout << "Please Select : Teacher [A] or Student [B] \n";
  72.  
  73. //if (userSelect == 'a' || 'A')
  74. //{
  75. // cout << "Welcome Educator. Please Login :\n";
  76. // cin >> userSelect;
  77. //
  78. //}
  79.  
  80.  
  81. //cin >> userSelect;
  82.  
  83.  
  84. while (loginAttempt < 5)
  85. {
  86. cout << "ENTER User Name: ";
  87. cin >> teacherUser;
  88. cout << "ENTER User Password: ";
  89. cin >> teacherPassword;
  90. cout << endl;
  91.  
  92. if (teacherUser == "Natasha" && teacherPassword == "CPSC120" || "cpsc120")
  93. {
  94. cout << "Hello Professor Natasha Anderson!\n";
  95. cout << endl;
  96.  
  97.  
  98.  
  99. break;
  100. }
  101. else if (studentUser == " " && studentPassword == "1234")
  102. {
  103. cout << "Hello Student User! \n";
  104.  
  105. dataFile.open("QuestionBank.txt");
  106.  
  107. while (a<22) // To get you all the lines.
  108. {
  109. getline(dataFile, questons); // Saves the line in STRING.
  110. if (questons != previousLine)
  111. {
  112. previousLine = questons;
  113. cout << questons << endl; // Prints our STRING.
  114. }
  115.  
  116. }
  117.  
  118. dataFile.close();
  119.  
  120. break;
  121. }
  122. else
  123. {
  124. cout << "Invalid login attempt. Please try again.\n" << '\n';
  125. loginAttempt++;
  126. }
  127. }
  128.  
  129. if (loginAttempt == 5)
  130. {
  131. cout << "Too many login attempts! The program will now terminate.";
  132. return 0;
  133. }
  134.  
  135. cout << "Thank you for logging in.\n";
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. //dataFile.open("QuestionBank.txt");
  161.  
  162. //while (a<22) // To get you all the lines.
  163. //{
  164. // getline(dataFile, questons); // Saves the line in STRING.
  165. // if (questons != previousLine)
  166. // {
  167. // previousLine = questons;
  168. // cout << questons << endl; // Prints our STRING.
  169. // }
  170.  
  171. //}
  172.  
  173. //dataFile.close();
  174.  
  175. return 0;
  176.  
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement