Guest User

Untitled

a guest
Jan 9th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.93 KB | None | 0 0
  1. #include <conio.h>
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5. #include <windows.h>
  6. #include <thread>
  7. #include <chrono>
  8. using namespace std;
  9. void adddata();
  10. void search();
  11. int main()
  12. {
  13. string userName;
  14. string userPassword;
  15. int loginAttempt = 0;
  16.  
  17. region:
  18. system ("title Student Managment System") ;
  19. system ("CLS");
  20. int choice,username,password ;
  21. system ("color 0F");
  22. 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--------------------------";
  23.  
  24. for (const auto c : s)
  25. {
  26. std::cout << c << std::flush;
  27. std::this_thread::sleep_for(std::chrono::milliseconds(50));
  28. }
  29. std::cout << std::endl;
  30.  
  31. while (loginAttempt < 5)
  32. {
  33. cout << "\nEnter your login credentials";
  34. cout << "\n\nUsername: ";
  35. cin >> userName;
  36. cout << "Password: ";
  37. cin >> userPassword;
  38.  
  39. if (userName == "bckk" && userPassword == "1234")
  40. {
  41. break;
  42. }
  43. else
  44. {
  45. cout << "Invalid login attempt. Please try again.\n" << '\n';
  46. loginAttempt++;
  47. }
  48. }
  49. if (loginAttempt == 5)
  50. {
  51. cout << "Too many login attempts! The program will now terminate.";
  52. return 0;
  53. }
  54.  
  55. cout << "\nYou've been logged in, switching to main menu in 3 seconds'.\n";
  56. Sleep(3000);
  57.  
  58. mainmenu:
  59. system("CLS");
  60. printf("Welcome to MAIN MENU");
  61. printf("\nWhat will you like to perform");
  62. printf("\n\n1. Create a new record");
  63. printf("\n2. Edit the a existing record");
  64. printf("\n3. Find the record of a student");
  65. printf("\n4. Logout");
  66. printf("\n\nEnter your choice:");
  67. scanf("%d",&choice);
  68. {
  69. if (choice == 1)
  70. {
  71. adddata();
  72. goto mainmenu;
  73. }
  74. else if (choice == 2)
  75. {
  76. printf("to be coded");
  77. }
  78. else if (choice == 3)
  79. {
  80. search ();
  81. goto mainmenu;
  82. }
  83. else if (choice == 4 )
  84. {
  85. cout << "\n Logging out ";
  86. Sleep(1500);
  87. system ("CLS");
  88. goto region;
  89. }
  90. else
  91. {
  92. printf("\nEnter the correct choice");
  93. }
  94. }
  95. }
  96. void adddata ()
  97. {
  98. string name,fname ;
  99. int ID,eng,urdu,isl,pst,maths,phy,comp,chem ;
  100. ofstream worker ("bckk.txt",ios ::app) ;
  101. system ("CLS");
  102. cout << "\nEnter Student's Name: " ;
  103. cin >> name ;
  104. cout << "\nEnter Student's Father Name: " ;
  105. cin >> fname ;
  106. cout << "\nEnter Students G.R. No: " ;
  107. cin >> ID ;
  108. std::string s = "\n=========================";
  109.  
  110. for (const auto c : s)
  111. {
  112. std::cout << c << std::flush;
  113. std::this_thread::sleep_for(std::chrono::milliseconds(50));
  114. }
  115. std::cout << std::endl;
  116. cout << "\nMarks Obtained in English: " ;
  117. cin >> eng ;
  118. cout << "\nMarks Obtained in Urdu: " ;
  119. cin >> urdu ;
  120. cout << "\nMarks Obtained in Islamiat: " ;
  121. cin >> isl ;
  122. cout << "\nMarks Obtained in P.S.T: " ;
  123. cin >> pst ;
  124. cout << "\nMarks Obtained in Maths: " ;
  125. cin >> maths ;
  126. cout << "\nMarks Obtained in Physics: " ;
  127. cin >> phy ;
  128. cout << "\nMarks Obtained in Chemistry: " ;
  129. cin >> chem ;
  130. cout << "\nMarks Obtained in Computer: " ;
  131. cin >> comp ;
  132. std::string ss = "\n=========================";
  133.  
  134. for (const auto c : ss)
  135. {
  136. std::cout << c << std::flush;
  137. std::this_thread::sleep_for(std::chrono::milliseconds(50));
  138. }
  139.  
  140. worker << name << ' ' << fname << ' ' << ID << ' ' << eng << ' ' << urdu << ' ' << isl << ' ' << pst << ' ' << maths << ' ' << phy << ' ' << chem << ' ' << comp << ' ' << endl;
  141. worker.close () ;
  142. system ("CLS");
  143. cout << endl;
  144. }
  145.  
  146. void search ()
  147. {
  148. ifstream worker ("bckk.txt") ;
  149. int ID,eng,urdu,isl,pst,maths,phy,comp,chem,str,PER,OBT ;
  150. string name,fname ;
  151. cout << "Enter G.R No. Of Student : " ;
  152. cin >> str ;
  153.  
  154. while (worker >> name >> fname >> ID >> eng >> urdu >> isl >> pst >> maths >> phy >> chem >> comp)
  155. {
  156. if (str == ID)
  157. {
  158. system ("cls") ;
  159. std::string ss = "\n==========STUDENT'S INFORMATION==========";
  160. for (const auto c : ss)
  161. {
  162. std::cout << c << std::flush;
  163. std::this_thread::sleep_for(std::chrono::milliseconds(50));
  164. }
  165. std::cout << std::endl;
  166. cout << "Student's Name : " << name << endl ;
  167. cout << "Student's Father name : " << fname << endl ;
  168. cout << "Student's G.R No : " << ID << endl ;
  169. std::string s = "\n============MARKS OBTAINED===============";
  170. for (const auto c : s)
  171. {
  172. std::cout << c << std::flush;
  173. std::this_thread::sleep_for(std::chrono::milliseconds(50));
  174. }
  175. std::cout << std::endl;
  176. cout << "\nMarks Obtained in English: " << eng << endl ;
  177. cout << "Marks Obtained in Urdu: " << urdu << endl ;
  178. cout << "Marks Obtained in Islamiat: " << isl << endl ;
  179. cout << "Marks Obtained in P.S.T: " << pst << endl ;
  180. cout << "Marks Obtained in Maths: " << maths << endl ;
  181. cout << "Marks Obtained in Physics: " << phy << endl ;
  182. cout << "Marks Obtained in Chemistry: " << chem<< endl ;
  183. cout << "Marks Obtained in Computer: " << comp << endl ;
  184. OBT=eng+urdu+isl+pst+maths+phy+chem+comp;
  185. PER=(OBT/550)*100;
  186. std::string sss = "\n=======================================";
  187. for (const auto c : sss)
  188. {
  189. std::cout << c << std::flush;
  190. std::this_thread::sleep_for(std::chrono::milliseconds(50));
  191. }
  192. std::cout << std::endl;
  193. cout << "Total Marks Obtained Out of 550: " << OBT << endl ;
  194. //cout << "Percentage " << obt << endl ;
  195. //cout << "Grade: " << obt << endl ;
  196. //cout << "Attendance: " << obt << endl ;
  197. cout << "\nPress any Key to return to Mainmenu " << endl ;
  198. system ("Pause");
  199.  
  200. }
  201. else if (!(str == ID))
  202. {
  203. system ("cls") ;
  204. cout << "Student's Record has not been Found'" << endl;
  205. }
  206. }
  207. }
Add Comment
Please, Sign In to add comment