// ***************************************************************** // Author: Zhixiang Chen // Class: CSCI/CMPE 1170, Spring 2009 // Lab Optional 4: Arrays of structures // Date: January 17, 2009 // Comment: The code here is meant to be revised. // ***************************************************************** #include #include #include #include using namespace std; #ifndef LAB_OPTIONAL_4_HEAD_H #define LAB_OPTIONAL_4_HEAD_H //define studentType structure struct studentType { string firstName, //firstnames for students lastName, //last names for students ID; //IDs for students double record[COLUMN]; //record of attendance, hw1, ..., hw6, quiz, test1, test2, test3 double score; //scores for students char grade; //letter grades }; /**************************************************************** This function gets class information from the input file and store the info to three parallel array and one two dim array. inFile: input file firstNames, lastNames, IDs: three output parallel arrays csci1380: an array of studentType SIZE, COLUMN: two input parameters ****************************************************************/ void loadData(ifstream & inFile, vector & csci1380, const int SIZE, const int COLUMN) { char str[1024]; //skip the first three lines inFile.getline(str, 1080, '\n'); cout<> csci1380[row].firstName //get first name >> csci1380[row].lastName //get last name >> csci1380[row].ID; //get ID for (int col = 0; col > csci1380[row].record[col]; //get a row for csci1380 } //initialize score and grade csci1380[row].score = 0; //0 initial score csci1380[row].grade = 'U'; //'U': undecided grade } } /**************************************************************** This function computes scores for each student and decides his/her grade. The formula to calculate the scores of attendance 5%, quiz 5%, homework 30%, tests 60%. The grade is decided as follows: A if score >= 90, B if 80<= score <90, C if 70<= score < 80, D if 60 <= score <70, and F otherwise. ****************************************************************/ void grading(vector & csci1380, //input/output array const int SIZE, const int COLUMN) //input parameters { //your code is here } /**************************************************************** This function displays class information for CSCI 1380 in some nice format. ****************************************************************/ void showGrades(const vector csci1380, const int SIZE, const int COLUMN) { for (int row=0; row