Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <windows.h>
- #include <thread>
- #include <chrono>
- using namespace std;
- void adddata();
- void search();
- void deletefind();
- int main()
- {
- string userName;
- string userPassword;
- int loginAttempt = 0;
- region:
- system ("title Student Managment System") ;
- system ("CLS");
- int choice,username,password ;
- system ("color 0F");
- std::string s = "\n\t\t\t\t _______\n\t\t\t\t|WELCOME|\n\t\t\t _______| TO |________\n\t\t\t|STUDENT DATABASE SYSTEM |\n\t\t\t--------------------------";
- for (const auto c : s)
- {
- std::cout << c << std::flush;
- std::this_thread::sleep_for(std::chrono::milliseconds(50));
- }
- std::cout << std::endl;
- while (loginAttempt < 5)
- {
- cout << "\nEnter your login credentials";
- cout << "\n\nUsername: ";
- cin >> userName;
- cout << "Password: ";
- cin >> userPassword;
- if (userName == "bckk" && userPassword == "1234")
- {
- 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 << "\nYou've been logged in, switching to main menu in 3 seconds'.\n";
- Sleep(3000);
- mainmenu:
- system("CLS");
- printf("Welcome to MAIN MENU");
- printf("\nWhat will you like to perform");
- printf("\n\n1. Create a new record");
- printf("\n2. Edit the a existing record");
- printf("\n3. Find the record of a student");
- printf("\n4. Logout");
- printf("\n\nEnter your choice:");
- scanf("%d",&choice);
- {
- if (choice == 1)
- {
- adddata();
- goto mainmenu;
- }
- else if (choice == 2)
- {
- deletefind();
- goto mainmenu;
- }
- else if (choice == 3)
- {
- search ();
- goto mainmenu;
- }
- else if (choice == 4 )
- {
- cout << "\n Logging out ";
- Sleep(1500);
- system ("CLS");
- goto region;
- }
- else
- {
- printf("\nEnter the correct choice");
- }
- }
- }
- void adddata ()
- {
- string name,fname ;
- int ID,eng,urdu,isl,pst,maths,phy,comp,chem ;
- ofstream bck ("bckk.txt",ios ::app) ;
- system ("CLS");
- cout << "\nEnter Student's Name: " ;
- cin >> name ;
- cout << "\nEnter Student's Father Name: " ;
- cin >> fname ;
- cout << "\nEnter Students G.R. No: " ;
- cin >> ID ;
- std::string s = "\n=========================";
- for (const auto c : s)
- {
- std::cout << c << std::flush;
- std::this_thread::sleep_for(std::chrono::milliseconds(50));
- }
- std::cout << std::endl;
- cout << "\nMarks Obtained in English: " ;
- cin >> eng ;
- cout << "\nMarks Obtained in Urdu: " ;
- cin >> urdu ;
- cout << "\nMarks Obtained in Islamiat: " ;
- cin >> isl ;
- cout << "\nMarks Obtained in P.S.T: " ;
- cin >> pst ;
- cout << "\nMarks Obtained in Maths: " ;
- cin >> maths ;
- cout << "\nMarks Obtained in Physics: " ;
- cin >> phy ;
- cout << "\nMarks Obtained in Chemistry: " ;
- cin >> chem ;
- cout << "\nMarks Obtained in Computer: " ;
- cin >> comp ;
- std::string ss = "\n=========================";
- for (const auto c : ss)
- {
- std::cout << c << std::flush;
- std::this_thread::sleep_for(std::chrono::milliseconds(50));
- }
- bck << name << ' ' << fname << ' ' << ID << ' ' << eng << ' ' << urdu << ' ' << isl << ' ' << pst << ' ' << maths << ' ' << phy << ' ' << chem << ' ' << comp << ' ' << endl;
- bck.close () ;
- system ("CLS");
- cout << endl;
- }
- void search ()
- {
- ifstream bck ("bckk.txt") ;
- int ID,eng,urdu,isl,pst,maths,phy,comp,chem,str;
- float OBT,PER;
- string name,fname ;
- cout << "Enter G.R No. Of Student : " ;
- cin >> str ;
- while (bck >> name >> fname >> ID >> eng >> urdu >> isl >> pst >> maths >> phy >> chem >> comp)
- {
- if (str == ID)
- {
- system ("cls") ;
- std::string ss = "\n==========STUDENT'S INFORMATION==========";
- for (const auto c : ss)
- {
- std::cout << c << std::flush;
- std::this_thread::sleep_for(std::chrono::milliseconds(50));
- }
- std::cout << std::endl;
- cout << "Student's Name : " << name << endl ;
- cout << "Student's Father name : " << fname << endl ;
- cout << "Student's G.R No : " << ID << endl ;
- std::string s = "\n============MARKS OBTAINED===============";
- for (const auto c : s)
- {
- std::cout << c << std::flush;
- std::this_thread::sleep_for(std::chrono::milliseconds(50));
- }
- std::cout << std::endl;
- cout << "\nMarks Obtained in English: " << eng << endl ;
- cout << "Marks Obtained in Urdu: " << urdu << endl ;
- cout << "Marks Obtained in Islamiat: " << isl << endl ;
- cout << "Marks Obtained in P.S.T: " << pst << endl ;
- cout << "Marks Obtained in Maths: " << maths << endl ;
- cout << "Marks Obtained in Physics: " << phy << endl ;
- cout << "Marks Obtained in Chemistry: " << chem<< endl ;
- cout << "Marks Obtained in Computer: " << comp << endl ;
- OBT=eng+urdu+isl+pst+maths+phy+chem+comp;
- PER=(OBT/550)*100;
- std::string sss = "\n=======================================";
- for (const auto c : sss)
- {
- std::cout << c << std::flush;
- std::this_thread::sleep_for(std::chrono::milliseconds(50));
- }
- std::cout << std::endl;
- cout << "Total Marks Obtained Out of 550: " << OBT << endl ;
- printf("Percentage: %.2f", PER);
- //cout << "Grade: " << << endl ;
- //cout << "Attendance: " << obt << endl ;
- cout << "\nPress any Key to return to Mainmenu " << endl ;
- system ("Pause");
- }
- else if (!(str == ID))
- {
- system ("cls") ;
- cout << "Student's Record has not been Found'" << endl;
- }
- }
- }
- void deletefind()
- {
- string deleteline;
- string line;
- ifstream in("bckk.txt");
- if (!in.is_open()) {
- cout << "Input file failed to open\n";
- }
- ofstream out("outfile.txt");
- cout << "Please Select the Record you would like to remove" << endl;
- cin >> deleteline;
- while (getline(in, deleteline)) {
- if (line != deleteline)
- out << line << endl;
- }
- in.close();
- out.close();
- remove("bckk.txt");
- rename("outfile.txt", "bckk.txt");
- cout << "\nChanges has Successfully been made...... Data Saved\n" << endl;
Add Comment
Please, Sign In to add comment