Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The intent of this assignment is to expose you to a program that creates a new d

ID: 653971 • Letter: T

Question

The intent of this assignment is to expose you to a program that creates a new data type by creating a class called Student. You will use the provided .cpp and .h files. You simply need to complete the implementation of the Student class. You do not need to change the main() program or the class declaration in the .h file.

BACKGROUND

A program has been created that will read student data from a text file (grades.txt). This document stores student names, both first and last names, the student EID, and a list of exam grades. Using a new data type, the Student class, the program will read multiple students into an array of Student objects. The program will then produce a report that lists all students, the course exam grades, the grade average and the letter grade for each student.

The program is mostly complete. It is your task to complete the implementation of the Student class. The class declaration has been created. Additionally, a skeleton for the class implementation has been created. You must simply complete the code for each of the class methods.

Below is the UML diagram for the Student class:

Student

firstName: string

lastName: string

EID: string

grades[20]: double

numGrades: int

+ String()
+ setFirstName(string newName): void
+ setLastName(string newName): void
+ setName(string name): void
+ setEID(string newEID): void
+ getFirstName(): string
+ getLastName(): string
+ getFullName(): string
+ getEID(): string
+ getNumGrades(): int
+ getGrade(int index): double
+ addGrade(double newGrade): void
+ getAverage(): double
+ getLetterGrade(): char

Method descriptions:

String() This is a constructor. With this class, the only data member that requires initialization is numGrades, which should be initialized to 0. The constructor method had been completed for you. Do not change.

void setFirstName(string newName) This method will set the data member firstName to the value that is passed to the method via the parameter newName.

void setLastName(string newName) This method will set the data member lastName to the value that is passed to the method via the parameter newName.

void setName(string newName) This method will accept a full name in the format John Doe. The method will parse the first and last name to store them in their respective data members, firstName and lastName.

void setEID(string newEID) This method will set the data member EID to the value that is passed to the method via the parameter newEID. But the method should only accept the newEID if the length of the string is 9 characters.

string getFirstName() This method will return the value of the data member firstName.

string getLastName() This method will return the value of the data member lastName.

string getFullName() This method will return the full name of the student in the format, John Doe.

string getEID() This method will return the EID of the student.

int getNumGrades() This method will return a value (integer) representing the number of exams the student has taken, for which the scores are stored in grades[].

double getAverage() This method will return the average exam score of the student based upon the exam grades stored in grades[].

void addGrade(double newGrade) This method will add an exam score to the grades[] array and increment the numGrades counter. However, the grade must be validated to be >0 before being added to the array.

double getGrade(int index) This method will retrieve an exam grade that is stored in the array at position index. The index must be validated to be a good index that is between 0 and (numGrades 1)

double getAverage() This method will calculate and return the average of the exam grades stored in grades[].

char getLetterGrade() This method will return the letter grade based upon the average, which must be determined by calling getAverage() and evaluating the cverage with regards to the 90/80/70/60 grade scale.

REQUIREMENTS

Complete the implementation of a command-line C++ program that meets the following requirements:

1.The source code file is stored in 3 file: Gradebook.cpp, Student.cpp and Student.h. The main() function, as well as some support functions have been created for you in the Gradebook.cpp file. You do not need to alter this file. You also do not need to alter the Student.h file. However, the Student.cpp is an incomplete implementation of the Student class. You much complete the Student class implementation. A skeleton of the implementation is provided. You will only add the method bodies.

2.Complete the methods based upon the method descriptions above and the comment block for each method.

3.Use the provided data file to test your class implementation. The program should compile and utilize your class to store the data from the data file. The program will then produce a report that lists all students with their respective grades, average, and letter grade.

HINTS:

1. Write out pseudocode and/or flowchart for each method BEFORE starting to write code. Step through your algorithm and make sure that all requirements are met. You might also use it as a basis for comments (i.e., I wouldn't always use the pseudocode as a comment verbatim, but you could modify it to make it a more useful comment).

2. Do not write all of the code at once and then try testing it. Write on setter and the matching getter and then test the program.

3. D O   N O T   W A I T   U N T I L   T H E   L A S T   M I N U T E   T O   S T A R T   T H I S P R O J E C T.

Student

firstName: string

lastName: string

EID: string

grades[20]: double

numGrades: int

+ String()
+ setFirstName(string newName): void
+ setLastName(string newName): void
+ setName(string name): void
+ setEID(string newEID): void
+ getFirstName(): string
+ getLastName(): string
+ getFullName(): string
+ getEID(): string
+ getNumGrades(): int
+ getGrade(int index): double
+ addGrade(double newGrade): void
+ getAverage(): double
+ getLetterGrade(): char

Explanation / Answer

#include <iostream>

#include<string>

using namespace std;

class Student

{

// Member variables declaration  

public:

                string firstName;

                string lastName;

string EID;

double grades[20];

int numGrades;

// Member functions declaration

                Student();

                void setFirstName(string newName);

                void setLastName(string newName);

                void setName(string newName);

                void setEID(string newEID);

                string getFirstName();

                string getLastName();

                string getFullName();

                string getEID();

                int getNumGrades();

                double getAverage();

                void addGrade(double newGrade);

                double getGrade(int index);

                double getAverage();

                char getLetterGrade();

};

// Member functions definitions

void Student:: setFirstName(string newName)

{

    firstName=newName;

}

void Student:: setLastName(string newName)

{

    lastName=newName;

}

void Student:: setEID(string newEID)

{

if(newEID.length()==9)   

EID=newEID;

}

string Student:: getFirstName()

{

return(firstName);

}

string Student:: getLastName()

{

return(lastName);

}

string Student:: getFullName()

{

return(firstName+” “+lastName);

}

string Student:: getEID()

{

return(EID);

}

int Student:: getNumGrades()

{

return(numGrades);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote