Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <cstring>
  4. #include <string>
  5. #include <iomanip>
  6. #include <cstdlib>
  7. #include <vector>
  8. //#include "student.h"
  9. #include "studentList.h"
  10. using namespace std;
  11.  
  12. const int fileNameSize = 20;
  13. ofstream outFile;
  14. //char inputFileName [fileNameSize+1];
  15. //char outputFilename [fileNameSize+1];
  16. studentList stList;
  17. string id, name;
  18.  
  19. void showmenu()
  20. {
  21. cout << "Please type in one of the following opotions: \n";
  22. cout << "L or l to load the student list \n";
  23. cout << "D or d to display the student data \n";
  24. cout << "P or p to process grades\n";
  25. cout << "C or c to change a student \n";
  26. cout << "A or a to add a student. \n";
  27. cout << "S or s to search for a particular student's information \n";
  28. cout << "R or r to print the total grades and letter grade \n";
  29. cout << "M or m to display this menu \n";
  30. cout << "E or e to save and exit \n";
  31. }
  32.  
  33. void loadStudents()
  34. {
  35.  
  36. string dummy;
  37. int hpScores[10];
  38. int tScores[4];
  39. ifstream inFile;
  40. student st;
  41. string filename;
  42. string name;
  43.  
  44. filename = "studentprofs.txt";
  45. cout << "Loading students... \n";
  46.  
  47. inFile.open(filename);
  48. cout << "open check" << endl;
  49.  
  50. if (!inFile)
  51. {
  52. cout << "Error, could not load/find file.";
  53. inFile.close();
  54. inFile.clear();
  55. return;// choice;
  56. }
  57. cout << name << endl;
  58. st.setName(name);
  59. while (!inFile.eof())
  60. {
  61. cout << "open flag";
  62. inFile >> name;
  63. cout << " " << name;
  64. inFile >> id; st.setID(id);
  65. cout << " " << id;
  66.  
  67. for (int i = 0; i<10; i++)
  68. {
  69. inFile >> hpScores[i];
  70. cout << " " << hpScores[i] << " ";//<< endl;
  71. }
  72. cout << endl;
  73.  
  74. st.setHPScores(hpScores);
  75. for (int i = 0; i<4; i++)
  76. {
  77. inFile >> tScores[i];
  78. cout << " " << tScores[i] << " ";//<< endl;
  79. }
  80. cout << endl;
  81. st.setTestScores(tScores);
  82. stList.addStudent(st);
  83. // inFile >> name;
  84. st.setName(name);
  85. }
  86.  
  87. }
  88.  
  89.  
  90. void displayStudentProfile()
  91. {
  92. cout << "Displaying data...\n";
  93. }
  94.  
  95. void processGrades()
  96. {
  97. cout << "Processing grades... \n";
  98. }
  99.  
  100. void changeGrades()
  101. {
  102. cout << "Changing student grade(s)...\n";
  103. }
  104.  
  105. void addStudent()
  106. {
  107. cout << "Adding student... \n";
  108. }
  109.  
  110. void searchStudent()
  111. {
  112. cout << "Searhing student...\n";
  113. }
  114.  
  115. void saveInfo()
  116. {
  117. cout << "Saving data...";
  118. }
  119.  
  120. void printGrades()
  121. {
  122. cout << "Printing total grades and letter grade...";
  123. }
  124.  
  125. int main()
  126. {
  127. int ilchk = 0;
  128. char choice = 'm';
  129. string wastedata;
  130. showmenu();
  131. cout << "Please indicate your choice of operation (m for menu): ";
  132. cin >> choice;
  133. while ((choice != 'e') && (choice != 'E') && ilchk<5)
  134. {
  135. switch (choice)
  136. {
  137. case 'l':
  138. case 'L': loadStudents(); cin.ignore(400, '\n'); cin.clear(); break;
  139. case 'd':
  140. case 'D': displayStudentProfile(); cin.ignore(400, '\n'); cin.clear(); break;
  141. case 'p':
  142. case 'P': processGrades(); cin.ignore(400, '\n'); cin.clear(); break;
  143. case 'c':
  144. case 'C': changeGrades(); cin.ignore(400, '\n'); cin.clear(); break;
  145. case 'a':
  146. case 'A': addStudent(); cin.ignore(400, '\n'); cin.clear(); break;
  147. case 's':
  148. case 'S': searchStudent(); cin.ignore(400, '\n'); cin.clear(); break;
  149. case 'r':
  150. case 'R': printGrades(); cin.ignore(400, '\n'); cin.clear(); break;
  151. case 'm':
  152. case 'M': showmenu(); cin.ignore(400, '\n'); cin.clear(); break;
  153. case 'e':
  154. case 'E': cin.ignore(400, '\n'); cin.clear(); break;
  155. default: cout << "Invalid command." << endl;
  156. }
  157. cout << "Please indicate your choice of operation (m for menu): ";
  158. cin >> choice;
  159. ilchk++;
  160. }
  161. saveInfo();
  162. cout << "Thank you, have a good one!\n";
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement