Develop the implementation file student.cpp

Assignment Help JAVA Programming
Reference no: EM13323442

Develop a Student class that has the following header file:

#ifndef STUDENT_H
#define STUDENT_H
#include <iostream>
#include <iomanip>
#include <string>
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:

(1) The data fields have self explanatory identifiers, and their meaning should be clear from the Introduction.

(2) The "set" functions allow the user to set the assessment task marks within the specified margins, e.g. setExamMark ensures that the examMark is in the appropriate range - from 0 to 50.

(3) The function getGrade() returns the student's grade, calculated as specified in the Introduction. The rest of the "get" functions simply return the values of the corresponding fields.

(4) The function passed() returns true if this student , has passed the course, and returns false otherwise (see the Introduction).

(5) friend ostream& operator<<(ostream& stream, const Student &) - the function overloads << operator, which allows a Student object information to be output in the following format:

Underwood Scott:
Assignment 1 8
Assignment 2 16
Lab Test 0
Exam 34
Grade P

(6) bool operator<(const Student &student)const - the function overloads < operator, which allows to compare student's full names lexicographically.

2. Class ITECH7603Class.

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<Student>*);
~ITECH7603Class();
void addStudent(Student*);
map<string,Student>* getGroup();
void save();
private:
map<string,Student>* group;
};
#endif

(1) The only field of the class is a pointer to a "map<string,Student>" object representing a teaching group(or class), which is a map (an associative STL container) that contains the pairs: Key: a student's full name (i.e. name + " " + surname)

Value: corresponding Student object. In this assignment you should assume that there are no different students with identical full names
in ITECH7603 teaching classes.

(2) void addStudent(Student* studentPtr)- the function adds the pair Key: (*studentPtr) student's full name
Value: (*studentPtr)
To the (*group) map;

Please note that instead of actual objects you are supposed to use pointers as function parameters.

(3) void save()- the function writes the Student objects stored as values in the (*group) map to the "ITECH7603Students.bin" file. "ITECH7603Students.bin" is a binary file, and you are required to write the objects to the file using something like out.write(reinterpret_cast<char*>(s), sizeof(Student));

(4) Constructor ITECH7603Class() and the destructor: A default constructor initializes dynamically the group field.
The destructor deletes the group pointer.

(5) Constructor ITECH7603Class(int dummy):

This constructor does not require any parameter. However, to distinguish it from the default constructor you should use some dummy argument (say of int type). This constructor opens the "ITECH7603Students.bin" file, if such file exists, and reads information from the file into the (*group) map using addStudent() function. If the file "ITECH7603Students.bin" does not exist, the constructor behaves as the default constructor.

(6) Constructor ITECH7603Class(set<Student>* students):

This constructor takes a set of Student objects (in fact, a pointer to the set) as an argument and adds students from the set to the (*group) map, i.e. initializes the group field.

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:

• firstNamesBoys.txt - contains first names for boys
• firstNamesGirls.txt - contains first names for girls
• lastNames.txt - contains last names

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:

(1) There are three three global variables declared in the program:

vector<string>* names = new vector<string>();
vector<string>* surnames = new vector<string>();
set<Student>* students = new set<Student>();

(2) The test program should define a function with the following prototype: void readInputFiles();

This function does the following:
• Opens and reads firstNamesBoys.txt. Each name should be read into a string and added to the vector<string>* names.
• Opens and reads firstNamesGirls.txt. Each name should be read into a string and added to the vector<string>* names.
• Opens and reads lastNames.txt. Each name should be read into a string and added to the vector<string>* surnames.

(3) 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:

• Value for first name is chosen randomly from the vector (*names).
• Value for surname is chosen randomly from the vector (*surnames).
• Values for the rest of fields are chosen randomly from the corresponding ranges, e.g. value for the examMark is a random value from 0 to 50.

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.

(4) The main function performs the following tasks:

• Invokes consecutively functions readInputFiles(), createRandomStudentSet(12).

• Then creates a ITECH7603Class object (or a pointer to the object) using the constructor ITECH7603Class(students), and saves it (to the file "ITECH7603Students.bin").

• Creates another ITECH7603Class object using the constructor with a "dummy" parameter and prints information of the Student objects from the (*group) map field of the class.

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

Note that the student names are printed in lexicographical order.


Attachment:- Assignment.rar

Reference no: EM13323442

Questions Cloud

Define the major dehydrohalogenation product of the reaction : Name the major dehydrohalogenation product of the reaction of 2-bromobutane with potassium tert-butoxide in tert-butyl alcohol. Explain
How fast do you and your image approach each other : When you walk toward a mirror you see your image approaching you. If you walk at 2 m/s, how fast do you and your image approach each other
How many hours should take an articulated wheel loader : How many hours should it take an articulated wheel loader equipped with a 4 yd bucket to load 3000 cu yd of gravel from a stockpike into rail cars if the average haul distance is 300 ft one way
Determine the force the man is pushing on the box : A large box with mass 45 kg is being pushed up a ramp at a 32 degree incline at a constant velocity by a man pushing parallel to the incline of 7.80 m. determine the force the man is pushing on the box
Develop the implementation file student.cpp : Required to implement the class to develop the implementation file Student.cpp that conforms to the following specifications
How to evaluate the ph of the solution : A buffer is prepared by mixing 161 mL of 0.193 M NaOH with 695 mL of 0.687 M sodium bicarbonate (NaHCO3). Given that the Ka1 of H2CO3 is 4.5 x 10-7 and the Ka2 is 4.7 x 10-11, calculate the pH of the solution.
How fast were you going as you exited the intersection : You are driving a car at the 25-mi/h speed limit when you observe the light at the intersection 68 m in front of you turn yellow. How fast were you going as you exited the intersection
What is the magnitude of the force that the shopper exerts : A person pushes a 19.6-kg shopping cart at a constant velocity for a distance of 27.3 m on a flat horizontal surface. What is the magnitude of the force that the shopper exerts
Calculate how much heat was added to the gas : A 10.0 cm radius piston compresses a gas isothermally from a height of 15.0 cm to 2.50 cm at a constant pressure of 2.0 atm. How much heat was added to the gas

Reviews

Write a Review

JAVA Programming Questions & Answers

  Program that uses random instead of scanner to play

Write a Java Program that uses Random instead of Scanner to play many rounds of Rock Paper Scissors. The user and computer will each randomly pick one and common rules of winning apply

  The williamsburg women''s club

The Williamsburg Women's Club offers scholarships to local high school students who meet any of several criteria. Write an application that prompts the user for a student's numeric high school grade point average (for example, 3.2), the student's num..

  Write a version of sumpairs

Write a version of sumPairs  that sums each component of the pairs separately, returning a pair consisting of the sum of the first components and the sum of the second components. So basically [(3,1)(10,3)] would return (13,4).

  Method that accepts a string object

Word Counter Write a method that accepts a String object as an argument and returns the number of words it contains. For instance, if the argument is "Four score and seven years ago" the method should return the number

  supply a student tester class that tests all methods

Implement a class Student. For the purpose of this exercise, a student has a name and a total quiz score. Supply an appropriate constructor and methods getName( ), addQuiz(int score), getTotalScore( ), and getAverageScore ( ).

  What are the values of these boolean expressions

Describe the steps for inserting a new item at the head of a linked list? Make sure you consider all possible incoming conditions.

  Write an object-oriented java program to manipulate data

I want a simple java solution matching all the specifications in the document. The java program has to be made using Eclipseversion 4.2.1.

  Document the current application describing major classes

Add to the Project Management tool the different planned activities needed to implement the changes to the solution and document the current application describing the major classes used by the application.

  Create an application that provides a solution

Create an application that provides a solution for problem 20.8 In addition to requirements specified in the description.

  Create file lab7.java with a main method.

Create file Lab7.java with a main method. Inside your main method, write a segment of code which instantiates an object of the Student class (This class has been created for you in the  Student.java  file that is provided as part of this lab).

  List various bindings that are needed to determine semantics

List the various bindings that are required to determine the semantics when the statement is executed. For each binding, indicate the binding time used for the language.

  Determine the type of moped

Write a driver class called MopedRental. This class should perform the following: asks the user to enter the size of the moped, the day of the week and the number of hours rented, creates the Moped object, based on the size, and displays the input..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd