Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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:

(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
#include
#include

class ITECH7603Class{
public:
ITECH7603Class();
ITECH7603Class(int dummy);
ITECH7603Class(set*);
~ITECH7603Class();
void addStudent(Student*);
map* getGroup();
void save();
private:
map* group;
};
#endif

(1) The only field of the class is a pointer to a "map" 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(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* 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* names = new vector();
vector* surnames = new vector();
set* students = new set();

(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* names.
• Opens and reads firstNamesGirls.txt. Each name should be read into a string and added to the vector* names.
• Opens and reads lastNames.txt. Each name should be read into a string and added to the vector* 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

Java, Programming

  • Category:- Java
  • Reference No.:- M9902744
  • Price:- $80

Guranteed 48 Hours Delivery, In Price:- $80

Have any Question?


Related Questions in Java

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As