Advertisement
Mizuhara_Chizuru

Vritika's Project

Jan 3rd, 2022
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include <cstring>
  5. using namespace std;
  6. int adminView();
  7. int studentView();
  8. int studentLogin();
  9. int checkCredentials(string userName, string password);
  10. int getAllStudentsbyRollNo();
  11. int deleteAllStudents();
  12. int deleteStudentbyRollno();
  13. int checkListOfStudentsRegistered();
  14. int checkPresenseCountbyRollno();
  15. int getListOfStudentsWithTheirPresenseCount();
  16. int registerStudent();
  17. int adminLogin();
  18. int registerStudent();
  19. int markMyAttendance(string username);
  20. int countMyAttendance(string username);
  21. int delay();
  22. int delay()
  23. {
  24. for(int i = 0; i<3; i ++)
  25. {
  26.     cout<<"\n Saving Records ...";
  27.     for(int ii = 0; ii<20000; ii ++)
  28.     {
  29.         for(int iii = 0; iii<20000; iii ++)
  30.         { }
  31.     }
  32. }
  33. cout<<"\n Exiting Now ...";
  34. for(int i = 0; i<3; i ++){
  35.    for(int ii = 0; ii<20000; ii ++) {
  36.      for(int iii = 0; iii<20000; iii ++){
  37.      }
  38.     }
  39. }
  40. return 0;
  41. }
  42. int adminView()
  43. {
  44. int goBack = 0;
  45. while(1)
  46. {
  47. system("cls");
  48. cout<<"\n 1 Register a Student";
  49. cout<<"\n 2 Delete All students name registered";
  50. cout<<"\n 3 Delete student by rollno";
  51. cout<<"\n 4 Check List of Student registered by userame";
  52. cout<<"\n 5 Check presense count of any student by Roll No";
  53. cout<<"\n 6 Get List of student with their attendance count";
  54. cout<<"\n 0. Go Back <- \n";
  55. int choice;
  56. cout<<"\n Enter you choice: ";
  57. cin>>choice;
  58. switch(choice)
  59. {
  60.     case 1: registerStudent();break;
  61.     case 2: deleteAllStudents(); break;
  62.     case 3: deleteStudentbyRollno(); break;
  63.     case 4: checkListOfStudentsRegistered(); break;
  64.     case 5: checkPresenseCountbyRollno(); break;
  65.     case 6: getListOfStudentsWithTheirPresenseCount(); break;
  66.     case 0: goBack = 1;break;
  67.     default: cout<<"\n Invalid choice. Enter again ";
  68.     getchar();
  69. }
  70. if(goBack == 1)
  71.   break;
  72. }
  73. return 0;
  74. }
  75. int studentLogin()
  76. {
  77. system("cls");
  78. cout<<"\n -------- Student Login ---------";
  79. studentView();
  80. delay();
  81. return 0;
  82. }
  83. int adminLogin()
  84. {
  85. system("cls");
  86. cout<<"\n --------- Admin Login --------";
  87. string username;
  88. string password;
  89. cout<<"\n Enter username : ";
  90. cin>>username;
  91. cout<<"\n Enter password : ";
  92. cin>>password;
  93. if(username=="vritika" && password=="tyagiwow")
  94. {
  95.     adminView();
  96.     getchar();
  97.     delay();
  98. }
  99. else
  100. {
  101. cout<<"\n Error ! Invalid Credintials..";
  102. cout<<"\n Press any key for main menu ";
  103. getchar();
  104. getchar();
  105. }
  106. return 0;
  107. }
  108. int checkStudentCredentials(string username, string password)
  109. {
  110. ifstream read;
  111. read.open("db.dat");
  112. if (read) {
  113. int recordFound = 0;
  114. string line;
  115. string temp = username + password + ".dat";
  116. cout<<"\n file name is : "<<temp;
  117. while(getline(read, line)) {
  118.     if(line == temp)
  119.     {
  120.         recordFound = 1;
  121.         break;
  122.     }
  123. }
  124. if(recordFound == 0)
  125.     return 0;
  126. else
  127.    return 1;
  128. }
  129. else
  130.    return 0;
  131. }
  132. int getAllStudentsbyName()
  133. {
  134. cout<<"\n List of All Students by their Name \n";
  135. cout<<"\n Please any key to continue..";
  136. getchar();
  137. getchar();
  138. return 0;
  139. }
  140. int getAllStudentsbyRollNo()
  141. {
  142. cout<<"\n List of All Students by their Roll No \n";
  143. cout<<"\n Please any key to continue..";
  144. getchar();
  145. getchar();
  146. return 0;
  147. }
  148. int deleteStudentbyRollno()
  149. {
  150. cout<<"\n Delete any Student by their Roll No \n";
  151. cout<<"\n Please any key to continue..";
  152. getchar();
  153. getchar();
  154. return 0;
  155. }
  156. int checkPresenseCountbyRollno()
  157. {
  158. cout<<"\n Check presense count of any Student by Roll No \n";
  159. cout<<"\n Please any key to continue.." ;
  160. getchar();
  161. getchar();
  162. return 0;
  163. }
  164. int checkAllPresenseCountbyRollno()
  165. {
  166. cout<<"\n Check presense count of All Students by Roll No & Name \n";
  167. cout<<"\n Please any key to continue.." ;
  168. getchar();
  169. getchar();
  170. return 0;
  171. }
  172. int studentView()
  173. {
  174. cout<<"\n ------- Student Login-------- \n";
  175. string username, password;
  176. cout<<"\n Enter username : ";
  177. cin>>username;
  178. cout<<"\n Enter password : ";
  179. cin>>password;
  180. int res=checkStudentCredentials(username, password);
  181. if(res==0)
  182. {
  183.    cout<<"\n Invalid Credentials !!";
  184.    cout<<"\n Press any key for Main Menu..";
  185.    getchar();
  186.    getchar();
  187.    return 0;
  188. }
  189. int goBack = 0;
  190. while(1)
  191. {
  192. system("cls");
  193. cout<<"\n 1 Mark Attendance fo Today ";
  194. cout<<"\n 2 Count my Attendance";
  195. cout<<"\n 0. Go Back <- \n";
  196. int choice;
  197. cout<<"\n Enter you choice: ";
  198. cin>>choice;
  199. switch(choice)
  200. {
  201.     case 1: markMyAttendance(username); break;
  202.     case 2: countMyAttendance(username); break;
  203.     case 0: goBack = 1;break;
  204.     default: cout<<"\n Invalid choice. Enter again ";
  205.     getchar();
  206. }
  207. if(goBack==1)
  208.   break;
  209. }
  210. return 0;
  211. }
  212. int markMyAttendance(string username)
  213. {
  214. cout<<"\n Mark Attendance for today !!";
  215. cout<<"\n Please any key to continue..";
  216. getchar();
  217. getchar();
  218. return 0;
  219. }
  220. int countMyAttendance(string username)
  221. {
  222. cout<<"\n Count my attendace for today !!";
  223. cout<<"\n Please any key to continue..";
  224. getchar();
  225. getchar();
  226. return 0;
  227. }
  228. int deleteAllStudents()
  229. {
  230. cout<<"\n In delete all students !!";
  231. cout<<"\n Please any key to continue..";
  232. getchar();
  233. getchar();
  234. return 0;
  235. }
  236. int checkListOfStudentRegistered()
  237. {
  238. cout<<"\n List of All registered registered !!";
  239. cout<<"\n Please any key to continue..";
  240. getchar();
  241. getchar();
  242. return 0;
  243. }
  244. int getListOfStudentsWithTheirPresenseCount()
  245. {
  246. cout<<"\n All Students with their Presense count !!";
  247. cout<<"\n Please any key to continue..";
  248. getchar();
  249. getchar();
  250. return 0;
  251. }
  252. int checkListOfStudentsRegistered(){
  253. cout<<"\n - Check List of Student Registered by Username-- ";
  254. ifstream read;
  255. read.open("db.dat");
  256. if(read)
  257. {   int recordFound =0;
  258.     string line;
  259.     while(getline(read, line))
  260.     {
  261.         char name[100];
  262.         strcpy(name, line.c_str());
  263.         char onlyname[100];
  264.         strncpy(onlyname, name, (strlen(name) - 4));
  265.         cout<<"\n"<<onlyname;
  266.     }
  267.      read.close();
  268. }
  269. else
  270.   cout<<"\n No Record found :(";
  271. cout<<"\n Please any key to continue..";
  272. getchar();
  273. getchar();
  274. return 0;
  275. }
  276. int registerStudent()
  277. {
  278.     cout<<"\n ----- Form to Register Student ---- \n";
  279.     string name, username, password, rollno, address, father, mother;
  280.     cout<<"\n Enter Name : ";     cin>>name;
  281.     cout<<"\n Enter Username : ";     cin>>username;
  282.     cout<<"\n Enter password : ";     cin>>password;
  283.     cout<<"\n Enter rollno : ";     cin>>rollno;
  284.     getchar();
  285.     char add[100];
  286.     cout<<"\n Enter address : ";     cin.getline(add, 100);
  287.     cout<<"\n Enter father : ";     cin>>father;
  288.     cout<<"\n Enter mother : ";     cin>>mother;
  289.     ifstream read;
  290.     read.open("db.dat");
  291.     if(read)
  292.     {
  293.       int recordFound =0;
  294.        string line;
  295.         while(getline(read, line))
  296.       {
  297.         if(line == username+".dat" )
  298.            {
  299.             recordFound = 1 ;
  300.             break;
  301.              }
  302.       }
  303.         if(recordFound == 1)
  304.         {
  305.         cout<<"\n Username already Register. Please choose another username ";
  306.         getchar();
  307.       getchar();
  308.         delay();
  309.         read.close();
  310.         return 0;
  311.         }
  312.     }
  313.     read.close();
  314.     ofstream out;
  315.     out.open("db.dat", ios::app);
  316.     out<<username+".dat"<<"\n";
  317.     out.close();
  318.     ofstream out1;
  319.     string temp = username+".dat";
  320.     out1.open(temp.c_str());
  321.     out1<<name<<"\n";   out1<<username<<"\n";   out1<<password<<"\n";
  322.     out1<<rollno<<"\n";     out1<<add<<"\n";    out1<<father<<"\n";
  323.     out1<<mother<<"\n";
  324.     out1.close();
  325.     cout<<"\n Student Registered Successfully !!";
  326.     cout<<"\n Please any key to continue..";
  327.     getchar(); getchar();
  328.     return 0;
  329. }
  330. int main(int argc, char** argv)
  331. {
  332. while(1)
  333. {
  334.     system("cls");
  335.     cout<<"\n Attendance Management System \n";
  336.     cout<<"-------------------------------------\n\n";
  337.     cout<<"1. Student Login\n";
  338.     cout<<"2. Admin Login\n";
  339.     cout<<"0. Exit\n";
  340.     int choice;
  341.     cout<<"\n Enter you choice: ";
  342.     cin>>choice;
  343.     switch(choice)
  344.     {
  345.     case 1: studentLogin(); break;
  346.     case 2: adminLogin(); break;
  347.     case 0:
  348.             while(1)
  349.             {
  350.             system("cls");
  351.             cout<<"\n Are you sure, you want to exit? y | n \n";
  352.             char ex;
  353.             cin>>ex;
  354.             if(ex == 'y' || ex == 'Y')
  355.                exit(0);
  356.             else if(ex == 'n' || ex == 'N')
  357.                  break;
  358.              else{
  359.                 cout<<"\n Invalid choice !!!";
  360.                 getchar();
  361.              }
  362.            }
  363.             break;
  364.     default: cout<<"\n Invalid choice. Enter again ";
  365.     getchar();
  366.     }
  367. }
  368. return 0;
  369. }
  370.  
Advertisement
RAW Paste Data Copied
Advertisement