You are on page 1of 4

#include <iostream> #include <string> #include <cmath> #include <ctime> #include <windows.h> #include <fstream> #include <conio.

h> #include <iomanip> using namespace std; //class class human { protected: string name; public: human(string name){ this ->name = name; } void display (string line){ cout<<"Name : "<<name <<endl << line; } }; class student: public human { protected: string studentID; public: student(string name,string studentID): human(name) { this->studentID =studentID; } }; class lecturer: public human { protected: string lecturerId; public: lecturer(string name, string lecturerId):human(name) { this->lecturerId = lecturerId; } }; class result { private: char FileName[20], firstname[20], lastname[20]; char w[15]; char sub1, sub2, sub3, sub4, sub5; double p1, p2, p3, p4, p5; double avgR; string major; string email; string faculty; public:

void void void void void };

menu(); Register(); Display(); Edit(); Delete();

int main(){ string user_ad; string pass_ad; string _user_ad; string _pass_ad; string user_st; string pass_st; string _user_st; string _pass_st; int selection; login: system("cls"); cout<<"username:"; getline(cin,user_ad); cout<<"password:"; getline(cin,pass_ad); cout<<endl; ifstream data; data.open("admin.txt"); if (data) { data.ignore(10); //ignoring "Username: " in the admin.txt getline(data,_user_ad); data.ignore(10); //ignoring "Password: " in the admin.txt getline(data,_pass_ad); //Verify Data from admin.txt File if (user_ad == _user_ad and pass_ad == _pass_ad) { cout << endl; cout<<"Login Successful!"<<endl; char date [9]; //declare date _strdate(date); //function that copies the current date to the b uffer pointed to by datestr. cout << endl; // col(11); //set the color to light blue color cout<<"Login date: "<<date<<endl; char time [9]; //declare time _strtime(time); //function copies the current time to the buffer pointed to by timestr. cout<<"Login time: "<<time<<endl<<endl; // col(7); //set the color to grey color system("pause"); result r; //declare variable c with class eyeclinic r.menu(); //output the main menu } else { ifstream data;

data.open("stu.txt"); if (data) { data.ignore(10); //ignoring "Username: " in the stu.txt getline(data,_user_st); data.ignore(10); //ignoring "Password: " in the stu.txt getline(data,_pass_st); //Verify Data from stu.txt File if (user_st == _user_st and pass_st == _pass_st) { cout << endl; cout<<"Login Successful!"<<endl; char date [9]; //declare date _strdate(date); //function that copies the current date to the b uffer pointed to by datestr. cout << endl; // col(11); //set the color to light blue color cout<<"Login date: "<<date<<endl; char time [9]; //declare time _strtime(time); //function copies the current time to the buffer pointed to by timestr. cout<<"Login time: "<<time<<endl<<endl; //col(7); //set the color to grey color system("pause"); result r; //declare variable c with class eyeclinic r.menu(); //output the main menu } else { cout << "Invalid Login!" << endl; //error message system("pause"); goto login; //jump to the loop point which is login } } } // else if // { // data.close(); //close the file // cout << "Invalid Login!!" << endl; //error message // system("pause"); // goto login; //jump to the loop point // } } return 0; } void result::menu(){ int selection; system("cls"); cout<<"review-----"<<endl; cout<<"1.register:"<<endl; cout<<"2.display:"<<endl; cout<<"3.modify:"<<endl; cout<<"4.delete:"<<endl; cout<<"enternum"<<endl;

cin>>selection; switch(selection){ if(selection ==1) case 1: Register(); break; if(selection==2) case 2: Display(); break; if(selection==3) case 3: Edit(); break; if(selection==4) return menu(); case 4: Delete(); break; default:cout<<"abkacangc "; } } void result::Register() { return(menu()); } void result::Display(){cout<<"2";} void result::Edit(){cout<<"3";} void result::Delete(){cout<<"4";}

You might also like