Guest User

Untitled

a guest
Apr 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. //************************************************************************
  2. // Programmer: Codye Watson
  3. // Course: CS-1313
  4. // Program: 6
  5. // Date: 12/09/2011
  6. // Purpose:
  7. // Input:
  8. // Calculate:
  9. // Output:
  10. //***********************************************************************
  11.  
  12. #include <iostream>
  13. #include <iomanip>
  14. #include <fstream> //Needed to use files
  15. using namespace std;
  16.  
  17. // This function opens the file datafile.txt, reads a collection of student records, and keeps track of the
  18. // number of records in variable size.
  19. void read(string name[ ], float gpa[ ], int &size);
  20.  
  21. // This function outputs each student name and GPA on a line.
  22. // The output will be aligned.
  23. void output(string name[ ], float gpa[ ], int size);
  24.  
  25. // This function receives a list of GPAs, and the number of students.
  26. // It calculates and returns the average GPA.
  27. float average(float gpa[ ], int size);
  28.  
  29. // This function receives student names and GPAs. It outputs each name, GPA, and the corresponding
  30. // letter grade on a line. The output will be aligned.
  31. void outputGrades(string name[], float gpa[], int size);
  32.  
  33. // This function receives a list of GPAs and returns the array index of the highest GPA.
  34. int highest(float gpa[], int size);
  35.  
  36. // This function receives a list of GPAs and returns the array index of the lowest GPA.
  37. int lowest(float gpa[], int size);
  38.  
  39. // This function receives GPAs. It outputs the total number of .A.s, .B.s. .C.s, .D.s, and .F.s.
  40. // Frequency ranges: "A" = 4.0, "B" = 3.0 to 3.9, "C" = 2.0 to 2.9, "D", 1.0 to 1.9, "F" = 0.0 to 0.9.
  41. void outputStats(float gpa[ ], int size);
  42.  
  43. int main(){
  44. const int MAXSIZE = 100;
  45. string name[MAXSIZE];
  46. float gpa[MAXSIZE];
  47. int size;
  48.  
  49. read(name, gpa, size); // Call the read function to read the file and store in arrays
  50.  
  51. output(name, gpa, size); // Call the output function to display the arrays and num of students
  52.  
  53. //outputGrades(name, gpa, size); // Call the outputGrades function to calculate and output grades
  54.  
  55. //cout << "Average GPA: " << average(gpa, size) << endl; // Output the average GPA
  56.  
  57. //index = highest(gpa, size); // Call the highest function to find the index of the highest GPA
  58.  
  59. //cout << "Highest GPA: " << name[index] << " " << gpa[index] << endl;
  60.  
  61. return 0;
  62.  
  63. }
  64.  
  65. void read(string name[], float gpa[], int &size){
  66. int index = 0;
  67.  
  68. //Open the data file
  69. ifstream inputFile;
  70. inputFile.open("datafile.txt");
  71. if (inputFile.fail()){
  72. cout << "Error: The file did not open." << endl;
  73. exit(1);
  74. }
  75. // read the entire data file and store in arrays name and gpa
  76. else {
  77. inputFile >> name[0];
  78. inputFile >> gpa[0];
  79. while(!inputFile.eof()){
  80. index++;
  81. inputFile >> name[index];
  82. inputFile >> gpa[index];
  83. }
  84. }
  85. exit(1);
  86. }
  87.  
  88. void output(string name[], float gpa[], int size){
  89. for (int index = 0; index < size; index++){
  90. cout << name[index] << endl;
  91. }
  92. }
  93.  
  94. float average(float gpa[], int size){
  95.  
  96. }
  97.  
  98. void outputGrades(string name[], float gpa[], int size){
  99.  
  100. }
  101.  
  102. int highest(float gpa[], int size){
  103.  
  104. }
  105.  
  106. int lowest(float gpa[], int size){
  107.  
  108. }
Add Comment
Please, Sign In to add comment