Guest User

Untitled

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