Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 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. int dummy = 1;
  36. //choice='1';
  37. //char temp=choice;
  38. int hpScores[10];
  39. int tScores[4];
  40. ifstream inFile;
  41. //cout << "infile flag";
  42. student st;
  43. char filename[30];
  44. cout << "What is the file we are reading from? \n";
  45. cin >> filename;
  46. cout << "Loading students... \n";
  47. cout << filename << endl;
  48. inFile.open(filename);
  49. cout << "open check" << endl;
  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. cout << " " << name;
  63. inFile >> id; st.setID(id);
  64. cout << " " << id;
  65. cin >> dummy;
  66. for(int i=0;i<10;i++)
  67. {
  68. inFile >> hpScores[i];
  69. cout << " " <<hpScores[i] << endl;
  70. }
  71. st.setHPScores(hpScores);
  72. for(int i=0;i<4;i++)
  73. {
  74. inFile >> tScores[i];
  75. cout << " " <<tScores[i] << endl;
  76. }
  77. st.setTestScores(tScores);
  78. stList.addStudent(st);
  79. inFile >> name;
  80. st.setName(name);
  81. }
  82. //cout << "flag6";
  83. //return choice;
  84. string wastedata;
  85. getline(cin, wastedata);
  86. inFile.clear();
  87. inFile.close();
  88.  
  89. }
  90.  
  91. void displayStudentProfile()
  92. {
  93. cout << "Displaying data...\n";
  94. }
  95.  
  96. void processGrades()
  97. {
  98. cout << "Processing grades... \n";
  99. }
  100.  
  101. void changeGrades()
  102. {
  103. cout << "Changing student grade(s)...\n";
  104. }
  105.  
  106. void addStudent()
  107. {
  108. cout << "Adding student... \n";
  109. }
  110.  
  111. void searchStudent()
  112. {
  113. cout << "Searhing student...\n";
  114. }
  115.  
  116. void saveInfo()
  117. {
  118. cout << "Saving data...";
  119. }
  120.  
  121. void printGrades()
  122. {
  123. cout << "Printing total grades and letter grade...";
  124. }
  125.  
  126. int main()
  127. {
  128. int ilchk=0;
  129. char choice='m';
  130. string wastedata;
  131. showmenu();
  132. cout << "Please indicate your choice of operation (m for menu): ";
  133. cin >> choice;
  134. while((choice!='e')&&(choice!='E') and ilchk<5)
  135. {
  136. switch(choice)
  137. {
  138. case 'l':
  139. case 'L': loadStudents(); cin.ignore(400, '\n'); cin.clear(); break;
  140. case 'd':
  141. case 'D': displayStudentProfile(); cin.ignore(400, '\n'); cin.clear(); break;
  142. case 'p':
  143. case 'P': processGrades(); cin.ignore(400, '\n'); cin.clear(); break;
  144. case 'c':
  145. case 'C': changeGrades(); cin.ignore(400, '\n'); cin.clear(); break;
  146. case 'a':
  147. case 'A': addStudent(); cin.ignore(400, '\n'); cin.clear(); break;
  148. case 's':
  149. case 'S': searchStudent(); cin.ignore(400, '\n'); cin.clear(); break;
  150. case 'r':
  151. case 'R': printGrades(); cin.ignore(400, '\n'); cin.clear(); break;
  152. case 'm':
  153. case 'M': showmenu(); cin.ignore(400, '\n'); cin.clear(); break;
  154. case 'e':
  155. case 'E': cin.ignore(400, '\n'); cin.clear(); break;
  156. default : cout << "Invalid command." << endl;
  157. }
  158. cout << "Please indicate your choice of operation (m for menu): ";
  159. cin >> choice;
  160. ilchk++;
  161. }
  162. saveInfo();
  163. cout << "Thank you, have a good one!\n";
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement