// ***************************************************************** // Author: Zhixiang Chen // Class: CSCI 1380.01, Summer I, 2008 // ***************************************************************** // Author: Zhixiang Chen // Class: CSCI 1380.01, Summer I, 2008 // Lab 31: Vector class template, structures // Date: June 24, 2008 // Comment: The code here is meant to be revised. // //----------------------------------------------------------------- // Lab Exercise 31: // // This lab exercise is to show how to use the vector class template and practice more about // structures. The problem is to define a strucure type studentType to represent a students in class CSCI 1380 // and use the vector class template to create a vector of studentType to represent all students in the class. // // The structure studentType consists of the following members( or fields): // (1) studentFirstName, (2) studentLastName, (3) studentID, (4) a double array to // store value of attendance, hw1, hw2, hw3, hw4, hw5, hw6, quiz, test1, test2, test3, // (5) score for the class, and (6) letter grade. // // Once the studentTpye has been defined, we shall create a vector of studentType to represent all // students in the class. // // The data is stored in file "lab_29_data.txt", and shall be loaded into the array. // // 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. // // Compile and run your program. When everything is fine, // print your .cpp file and turn it to me or Sergio // ***************************************************************** #include < iostream > #include #include < string > #include < cstring > #include < cmath> #include #include #include //include vector class template //define a const array size const int SIZE = 35; //class size const int COLUMN = 11; //column size #include "lab_optional_4_head.h" using namespace std; int main( ) { //file var ifstream inFile; //input file int i; //loop var /******************************************************************************** Part A: Some practice about vector class template *******************************************************************************/ vector cat; //create an int vector cat with size 0 vector dog(5); //creat a char vector dog with size 10 vector rat(5, 12); //create a double vector of rat with size 5 and all elements are initialized to 12.55 vector bat(rat); //create a double vector of bat, copying rat to bat for initialization //how to insert elements into vector, when the size zero for (i = 0; i<5; i++) cat.push_back(i+10); //push_back(...) add a value to the end of the vector //treat an vector as an array when the size is known for (i = 0; i csci1380(SIZE); //a studentType vector object of size SIZE //open file inFile.open("lab_29_data.txt"); if(!inFile) { cout<<"Fail to open lab_28_data.txt, and stop ."<