Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include<iostream>
- //#include<cmath>
- //#include<iomanip>
- //#include<string>
- //#include<fstream>
- //#include<sstream>
- //#include<cstdlib>
- //
- //using namespace std;
- //
- //int main()
- //{
- // const int SIZE = 24;
- // string quizArray[SIZE];
- // ifstream dataFile;
- // string question2;
- //
- // dataFile.open("QuestionBank.txt");
- //
- // if (!dataFile)
- // cout << "Error opening data file\n";
- // else
- // {
- // for (getline(dataFile, line))
- // {
- //
- // dataFile >> quizArray[i];
- //
- // }
- // /*dataFile.close();*/
- //
- //
- //
- //
- //
- // getline(dataFile, question2);
- //
- // dataFile.close();
- //
- // cout << question2;
- // }
- //
- // system("pause");
- // return 0;
- // }
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- using namespace std;
- int main()
- {
- char userSelect;
- string questons;
- ifstream dataFile;
- int a = 0;
- string previousLine = "";
- string teacherUser, studentUser;
- string teacherPassword, studentPassword;
- int loginAttempt = 0;
- vector <int> v;
- cout << "Welcome to Quiz Program \n";
- cout << "------------------------\n";
- cout << endl;
- cout << "Please Select : Teacher [A] or Student [B] \n";
- //if (userSelect == 'a' || 'A')
- //{
- // cout << "Welcome Educator. Please Login :\n";
- // cin >> userSelect;
- //
- //}
- //cin >> userSelect;
- while (loginAttempt < 5)
- {
- cout << "ENTER User Name: ";
- cin >> teacherUser;
- cout << "ENTER User Password: ";
- cin >> teacherPassword;
- cout << endl;
- if (teacherUser == "Natasha" && teacherPassword == "CPSC120" || "cpsc120")
- {
- cout << "Hello Professor Natasha Anderson!\n";
- cout << endl;
- break;
- }
- else if (studentUser == " " && studentPassword == "1234")
- {
- cout << "Hello Student User! \n";
- dataFile.open("QuestionBank.txt");
- while (a<22) // To get you all the lines.
- {
- getline(dataFile, questons); // Saves the line in STRING.
- if (questons != previousLine)
- {
- previousLine = questons;
- cout << questons << endl; // Prints our STRING.
- }
- }
- dataFile.close();
- break;
- }
- else
- {
- cout << "Invalid login attempt. Please try again.\n" << '\n';
- loginAttempt++;
- }
- }
- if (loginAttempt == 5)
- {
- cout << "Too many login attempts! The program will now terminate.";
- return 0;
- }
- cout << "Thank you for logging in.\n";
- //dataFile.open("QuestionBank.txt");
- //while (a<22) // To get you all the lines.
- //{
- // getline(dataFile, questons); // Saves the line in STRING.
- // if (questons != previousLine)
- // {
- // previousLine = questons;
- // cout << questons << endl; // Prints our STRING.
- // }
- //}
- //dataFile.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement