Advertisement
remmydev

Untitled

Feb 17th, 2024
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.18 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <conio.h>
  5. #include <Windows.h>
  6. using namespace std;
  7.  
  8.  
  9. // Structure for students
  10. struct student
  11. {
  12. string fname;
  13. string lname;
  14. string Registration;
  15. string ClassMajor;
  16. string grade;
  17. int Gpa;
  18. string GPA;
  19. string accelarated;
  20. string studentData;
  21. string studentName;
  22. string newGrade;
  23. string Borrowing_Book;
  24. }studentData;
  25.  
  26. //Classes
  27. struct classes
  28. {
  29. string S_C_math;
  30. int I_C_M_Math = 50;
  31. int I_C_math;
  32. }Class;
  33.  
  34. struct teacher
  35. {
  36. string fst_name;
  37. string lst_name;
  38. string qualification;
  39. string exp;
  40. string pay;
  41. string subj;
  42. string lec;
  43. string serves;
  44. string cel_no;
  45.  
  46. }tech[50];
  47.  
  48. void getlastLine(string filename)
  49. {
  50. ifstream fin;
  51. fin.open(filename);
  52. if (fin.is_open()) {
  53. fin.seekg(-1, ios_base::end);
  54.  
  55. bool keepLooping = true;
  56. while (keepLooping) {
  57. char ch;
  58. fin.get(ch);
  59.  
  60. if ((int)fin.tellg() <= 1) {
  61. fin.seekg(0);
  62. keepLooping = false;
  63. }
  64. else if (ch == '\n') {
  65. keepLooping = false;
  66. }
  67. else {
  68. fin.seekg(-2, ios_base::cur);
  69. }
  70. }
  71.  
  72. string lastLine;
  73. getline(fin, lastLine);
  74. Class.S_C_math = lastLine;
  75. Class.I_C_math = stoi(lastLine);
  76.  
  77.  
  78. fin.close();
  79. }
  80.  
  81.  
  82. }
  83.  
  84. static void Hello() {
  85. cout << "hello boys";
  86. }
  87.  
  88. int main()
  89. {
  90. char choice;
  91. string find;
  92. string srch;
  93. int i = 0, j;
  94.  
  95. while (1)
  96. {
  97. cout << "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\";
  98. cout << "\n\n\t\t\tSCHOOL MANAGEMENT PROGRAM\n\n";
  99. cout << "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\";
  100. cout << "\n\n\t\t\tMAIN SCREEN\n\n";
  101. cout << "Enter your choice: " << endl;
  102. cout << "1.Students information" << endl;
  103. cout << "2.Teacher information" << endl;
  104. cout << "3.Check amount of people in a class" << endl;
  105. cout << "4.Add or Look For Students Borrowing books" << endl;
  106. cout << "5.Exit program" << endl;
  107. cin >> choice;
  108.  
  109.  
  110.  
  111. system("cls");
  112.  
  113. switch (choice)
  114. {
  115. case '1':
  116. {
  117. Hello();
  118.  
  119. while (1)
  120. {
  121.  
  122. cout << "\t\t\t Student Information And Data\n\n\n";
  123. cout << "Enter Your choice: " << endl;
  124. cout << "1.Create New Entry" << endl;
  125. cout << "2.Find and Display entry" << endl;
  126. cout << "3.Jump to main" << endl;
  127. cin >> choice;
  128. switch (choice)
  129. {
  130. case '1':
  131. {
  132. ofstream f1("Students.txt", ios::app);
  133. for (i = 0; choice != 'n' && choice != 'N'; i++)
  134. {
  135. cout << "Enter First name: ";
  136. cin >> studentData.fname;
  137. cout << "Enter Last name: ";
  138. cin >> studentData.lname;
  139. cout << "Enter Registration number: ";
  140. cin >> studentData.Registration;
  141. cout << "Enter class: ";
  142. cin >> studentData.ClassMajor;
  143. cout << "Enter Students Grade: ";
  144. cin >> studentData.grade;
  145. cout << "Enter Students Gpa: ";
  146. cin >> studentData.GPA;
  147. cout << "Enter True if student is borrowing a book enter False if not: ";
  148. cin >> studentData.Borrowing_Book;
  149. studentData.Gpa = stoi(studentData.GPA);
  150. if (studentData.Gpa >= 3.6)
  151. {
  152. studentData.accelarated = "True";
  153. }
  154. f1 << studentData.fname << endl << studentData.lname << endl << studentData.Registration << endl << studentData.ClassMajor << endl << studentData.grade << endl << studentData.GPA << endl << studentData.accelarated << endl << studentData.Borrowing_Book << endl;
  155.  
  156. cout << "Do you want to countinue Adding student? Y to continue N to stop: ";
  157. cin >> choice;
  158. }
  159.  
  160. f1.close();
  161. }
  162. continue;
  163.  
  164. case '2':
  165. {
  166. ifstream f2("Students.txt");
  167. cout << "Enter First name to be displayed: ";
  168. cin >> find;
  169. cout << endl;
  170. int notFound = 0;
  171. while (getline(f2, studentData.fname)) {
  172. if (studentData.fname == find)
  173. {
  174. notFound = 1;
  175.  
  176. cout << "First Name: " << studentData.fname << endl;
  177. getline(f2, studentData.lname);
  178. cout << "Last Name: " << studentData.lname << endl;
  179.  
  180. getline(f2, studentData.Registration);
  181. cout << "Registration No number: " << studentData.Registration << endl;
  182. getline(f2, studentData.ClassMajor);
  183. cout << "Class: " << studentData.ClassMajor << endl;
  184. getline(f2, studentData.grade);
  185. if (studentData.ClassMajor == "math")
  186. {
  187. Class.I_C_math += 1;
  188. }
  189. cout << "Grade: " << studentData.grade << endl;
  190. getline(f2, studentData.GPA);
  191. cout << "Gpa: " << studentData.GPA << endl;
  192. getline(f2, studentData.accelarated);
  193. cout << "Accelarated: " << studentData.accelarated << endl << endl;
  194. }
  195.  
  196. }
  197. f2.close();
  198. if (notFound == 0) {
  199.  
  200. cout << "No Record Found\n" << endl;
  201. }
  202. cout << "Press any key two times to proceed" << endl << endl;
  203. _getch();
  204. _getch();
  205.  
  206. }
  207. continue;
  208. case '3':
  209. {
  210. break;
  211. system("cls");
  212. }
  213. }
  214. break;
  215. }
  216. continue;
  217. }
  218. case '2':
  219. {
  220. while (1)
  221. {
  222. system("cls");
  223. cout << "\t\t\tTeachers Info and Data\n\n\n";
  224. cout << "Enter your choice: " << endl;
  225. cout << "1.Create new entry\n";
  226. cout << "2.Find and display\n";
  227. cout << "3.Jump to main\n";
  228. cin >> choice;
  229.  
  230. switch (choice)
  231. {
  232. case '1':
  233. {
  234. ofstream t1("Teachers.txt", ios::app);
  235. for (i = 0; choice != 'n' && choice != 'N'; i++)
  236. {
  237. if ((choice == 'y') || (choice == 'Y') || (choice == '1'))
  238. {
  239. cout << "Enter First name: ";
  240. cin >> tech[i].fst_name;
  241. cout << "Enter Last name: ";
  242. cin >> tech[i].lst_name;
  243. cout << "Enter qualification: ";
  244. cin >> tech[i].qualification;
  245. cout << "Enter experiance(year): ";
  246. cin >> tech[i].exp;
  247. cout << "Enter number of year in this School: ";
  248. cin >> tech[i].serves;
  249. cout << "Enter Subject whos teach: ";
  250. cin >> tech[i].subj;
  251. cout << "Enter Lecture(per Week): ";
  252. cin >> tech[i].lec;
  253. cout << "Enter pay: ";
  254. cin >> tech[i].pay;
  255. cout << "Enter Phone Number: ";
  256. cin >> tech[i].cel_no;
  257.  
  258.  
  259. t1 << tech[i].fst_name << endl << tech[i].lst_name << endl << tech[i].qualification << endl << tech[i].exp << endl << tech[i].serves << endl << tech[i].subj << endl << tech[i].lec << endl << tech[i].pay << endl << tech[i].cel_no << endl;
  260.  
  261. cout << "Do you want to enter any more data: ";
  262. cout << "Press Y to Continue and N to Finish: ";
  263. cin >> choice;
  264.  
  265. }
  266. }
  267.  
  268. system("cls");
  269.  
  270. t1.close();
  271. }
  272.  
  273. case '2':
  274. {
  275. ifstream t2("Teachers.txt");
  276. cout << "Enter First name to be displayed: ";
  277. cin >> find;
  278. cout << endl;
  279. int notFound = 0;
  280. while (getline(t2, studentData.fname)) {
  281.  
  282. if (tech[j].fst_name == find)
  283. {
  284. notFound = 1;
  285. cout << "First name: " << tech[j].fst_name << endl;
  286. getline(t2, tech[j].lst_name);
  287. cout << "Last name: " << tech[j].lst_name << endl;
  288. getline(t2, tech[j].qualification);
  289. cout << "Qualification: " << tech[j].qualification << endl;
  290. getline(t2, tech[j].exp);
  291. cout << "Experience: " << tech[j].exp << endl;
  292.  
  293. getline(t2, tech[j].serves);
  294. cout << "number of year in this School: " << tech[j].serves << endl;
  295.  
  296. getline(t2, tech[j].subj);
  297. cout << "Subject whos teach: " << tech[j].subj << endl;
  298.  
  299. getline(t2, tech[j].lec);
  300. cout << "Enter Lecture(per Week): " << tech[j].lec << endl;
  301. getline(t2, tech[j].pay);
  302. cout << "pay: " << tech[j].pay << endl;
  303.  
  304. getline(t2, tech[j].cel_no);
  305. cout << "Phone Number: " << tech[j].cel_no << endl << endl;
  306. }
  307.  
  308. }
  309. t2.close();
  310. if (notFound == 0) {
  311.  
  312. cout << "No Record Found" << endl;
  313. }
  314. cout << "Press any key two times to proceed";
  315. _getch();
  316. _getch();
  317.  
  318. }
  319. continue;
  320. case '3':
  321. {
  322. break;
  323. system("cls");
  324. }
  325. }
  326. break;
  327. }
  328. continue;
  329. }
  330. case '3':
  331. {
  332. ifstream c2("Class.txt");
  333.  
  334. getlastLine("Class.txt");
  335. cout << "Math Class: " << Class.S_C_math << "/" << Class.I_C_M_Math << endl;
  336. cout << "Press any key two times to proceed" << endl;
  337. _getch();
  338. _getch();
  339. continue;
  340. }
  341.  
  342. case '4':
  343. {
  344. cout << "\t\t\tLibraray System Information\n\n\n";
  345. cout << "1.look for students Borrowing books" << endl;
  346. cout << "2.Jump To Main" << endl;
  347. cin >> choice;
  348. while (1)
  349. {
  350. switch (choice)
  351. {
  352.  
  353. case '1':
  354. {
  355. ifstream f2("Students.txt");
  356. cout << "Enter First name to be displayed: ";
  357. cin >> find;
  358. cout << endl;
  359. int notFound = 0;
  360. for (j = 0; (j < i) || (!f2.eof()); j++)
  361. {
  362.  
  363. getline(f2, studentData.fname);
  364.  
  365. if (studentData.fname == find && studentData.Borrowing_Book == "true" || studentData.Borrowing_Book == "True")
  366. {
  367. notFound = 1;
  368. cout << "First Name: " << studentData.fname << endl;
  369. getline(f2, studentData.lname);
  370. cout << "Last Name: " << studentData.lname << endl;
  371.  
  372. getline(f2, studentData.Registration);
  373.  
  374. getline(f2, studentData.ClassMajor);
  375.  
  376. getline(f2, studentData.grade);
  377.  
  378. getline(f2, studentData.GPA);
  379.  
  380. getline(f2, studentData.accelarated);
  381.  
  382. getline(f2, studentData.Borrowing_Book);
  383. cout << "Borrowing book or books: " << studentData.Borrowing_Book << endl;
  384. }
  385. break;
  386. }
  387.  
  388. if (notFound == 0) {
  389.  
  390. cout << "No Record Found" << endl;
  391. cout << "Student is not Borrowing book or does not exist" << endl;
  392. }
  393. cout << "Press any key two times to proceed";
  394. _getch();
  395. _getch();
  396. }
  397. case '2':
  398. {
  399. break;
  400. }
  401. }
  402. break;
  403. }
  404. continue;
  405. }
  406.  
  407. case '5':
  408. {
  409. break;
  410. }
  411. }
  412. break;
  413. }
  414. }
  415.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement