In this assignment you are required to develop a program that allows the creation, viewing and storage of information about ITECH7603 Students. In order to complete the task you have to investigate how to use the following STL(Standard Template Library) containers - vector, set, and map.
The information about ITECH7603 students consists of: first name, surname, and marks for Lab Test, Assignment1, Assignment2, and Final Exam. This information should be stored in the binary file “ITECH7603Students.bin”. The program should also calculate and display the marks and grade for each student.
The following describes how to calculate the marks and grade:
Lab Test Mark – is an integer from 0 to 10;
Assignment1 Mark – is an integer from 0 to 20;
Assignment2 Mark – is an integer from 0 to 20;
Final exam Mark – is an integer from 0 to 50;
A total mark is a sum of the previous four marks, so it is an integer from 0 to 100.
A student passes the course if and only if (Assignment1 Mark + Assignment2 Mark) >= 20 and (Lab Test Mark + Final Exam Mark) >= 30
There are 5 grades, which are calculated according to the following rules:
F – if the Total Mark is less then 40;
MF – if (40 <= Total Mark < 50) or (Total Mark >= 50 but student didn’t pass);
P – if (50 <= Total Mark < 60) and student passed;
C – if (60 <= Total Mark < 70) and student passed;
D – if (70 <= Total Mark < 80) and student passed;
HD – if Total Mark >= 80;
Develop a Student class that has the following header file:
#ifndef STUDENT_H
#define STUDENT_H
#include
#include
#include
using namespace std;
class Student{
public:
Student();
Student(string name,string surname,int a1, int a2, int test, int exam);
string getName()const;
string getSurname()const;
int getAssignment1Mark()const;
int getAssignment2Mark()const;
int getLabTestMark()const;
int getExamMark()const;
void setAssignment1Mark(int);
void setAssignment2Mark(int);
void setLabTestMark(int);
void setExamMark(int);
bool passed()const;
string getGrade()const;
friend ostream& operator<<(ostream& stream, const Student &);
bool operator<(const Student &)const;
private:
string name;
string surname;
int assignment1Mark;
int assignment2Mark;
int labTestMark;
int examMark;
};
#endif
You are required to implement the class, i.e. to develop the implementation file “Student.cpp” that conforms to the following specifications:
Underwood Scott:
Assignment 1 8
Assignment 2 16
Lab Test 0
Exam 34
Grade P
The class has the following header file. Objects of this class represent ITECH7603 teaching classes (student groups).
#ifndef ITECH7603CLASS_H
#define ITECH7603CLASS_H
#include "Student.h"
#include set
#include map
#include fstream
class ITECH7603Class{
public:
ITECH7603Class();
ITECH7603Class(int dummy);
ITECH7603Class(set*);
~ITECH7603Class();
void addStudent(Student*);
map* getGroup();
void save();
private:
map* group;
};
#endif
You are required to implement the class, i.e. to develop the implementation file “ITECH7603Class.cpp” that conforms to the following specifications:
This is a test program that tests the Student and ITECH7603Class classes.
In this assignment you are provided with three input text files associated with this program:
Each of these input files contains one name per line. Hence “firstNamesBoys.txt” will contain one boy’s name per line, and “lastNames.txt” contains one surname per line. These input files will be used to create a random set of Student objects to test your application.
The test program should conform to the following specifications:
vector* names = new vector();
vector* surnames = new vector();
set* students = new set();
void readInputFiles();
This function does the following:
The test program should define a function with the following prototype:
void createRandomStudentSet(int n);
This function creates Student objects choosing values for their fields randomly:
If thus created Student object has passed the course it is added to the (*students) set (an associative container from STL). You should continue adding random Student objects to the set until the total number of Student objects in the set is n.
The main function performs the following tasks:
The following is a sample output of the test program (number of students is 5):
Adams Tiana:
Assignment 1 17
Assignment 2 5
Lab Test 4
Exam 34
Grade C
Barley Tia:
Assignment 1 9
Assignment 2 19
Lab Test 5
Exam 41
Grade D
Cameron Trent:
Assignment 1 19
Assignment 2 10
Lab Test 4
Exam 41
Grade D
Cannon Isabel:
Assignment 1 17
Assignment 2 19
Lab Test 8
Exam 25
Grade C
Davis Chelsea:
Assignment 1 3
Assignment 2 19
Lab Test 6
Exam 40
Grade C