this is what i have so far.....
Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <string>
- #include <vector>
- #include <fstream>
- using namespace std;
- //structure that holds student record information.
- struct records
- {
- string name;
- float quizzes[7];
- float projects[6];
- float exams[2];
- float labs[14];
- };
- const int num_quiz = 7;
- const int num_exams = 2;
- const int num_projects = 6;
- const int num_labs = 14;
- const int quiz_pts = 70;
- const int exam_pts = 200;
- const int projects_pts = 300;
- const int lab_pts = 150;
- get_scores(string name, int num_scores);
- int main()
- {
- // Ask the user for a file name
- cout << "Enter a file name: ";
- string file;
- cin >> file;
- cout << file;
- int counter = 1;
- ifstream in_file;
- record grades;
- // Define a file input stream and open the file
- in_file.open("file.txt"); //opening file
- if (in_file.fail())
- {
- // Failed to open the file (file doesn't exist or isn't readable)
- cout << "Could not open file: " << file << "\n";
- exit(1);
- }
- float quiz_ave = 0.0;
- float exam_ave = 0.0;
- float project_ave = 0.0;
- float lab_ave = 0.0;
- // Repeatedly get characters from the file
- get_scores(num_quiz); //function for inputing info in struct.
- get_scores(num_projects);
- get_scores(num_exams);
- get_scores(num_labs);
- // Close the file
- in_file.close();
- return 0;
- }
- //function that takes in parameters to input scores in array
- get_scores(int num_scores)
- {
- int index = 0;
- in_file >> student.name;
- for (int i = 0; i < num_scores; i++)
- {
- in_file >> student.quizes[i];
- float quiz_ave += student.quizes[i];
- }
- }