Question: LAB (50%) Student Transcript Your task for this lab is to create program that provides a class calledTranscriptthat can be initiated using a student name
LAB (50%) Student Transcript
Your task for this lab is to create program that provides a class calledTranscriptthat can be initiated using a student name and number of completedSubjects by the student.
Then theSubjects will be added one at the time to the Transcript by their name and the mark received for the subject out of 100.
TheTranscriptthen can be displayed as a report. All the marks in the transcript should be converted to grades using the following table and the GPA should be calculated and displayed at the bottom of the page using the Scale 4 mark.
Marks and their Grade and Scale 4 conversions
MarkGradeScale 4 mark0 =< Mark < 50F0.050 <= Mark < 60D1.060 <= Mark < 70C2.070 <= Mark < 80B3.080 <= Mark <= 100A4.0
Sample main program and execution sample
#include "Transcript.h" using namespace sdds; int main() { Transcript T; T.init("Fred Soley", 5); T.add("EAC150", 65); T.add("DBS211", 85); T.add("DCF255", 75); T.add("OOP244", 95); // Premature call to display will result an error T.display(); T.add("WEB222", 100); // Proper and timely call to display transcript T.display(); T.deallocate(); return 0; } Invalid Transcirpt! Fred Soley ----------------------------- EAC150 65 C DBS211 85 A DCF255 75 B OOP244 95 A WEB222 100 A ----------------------------- GPA: 3.4
Implementation
Implement this program in two modules (ie. classes):
SubjectandTranscript
Files to submit:
transcriptTester.cpp <--- contains the main function Subjct.cpp Subjct.h Transcript.cpp Transcript.h
The Subject Class
Develop this class in filesSubject.handSubject.cpp
Private Member Variables (attributes)
The class subject should have the following member variables:
char m_code[7]; // holds the subject code (exactly 6 characters) int m_mark; // the mark out of 100
Private Member functions (Methods)
char grade()const; This function returns the grade value of the mark held in the m_mark attribute and is incapable of modifying its owner (Subject)
See theMarks and their Grades tableto form your selection algorithm for the grade.
Public Member functions (Methods)
void setEmpty(); Sets theSubjectto a recognizable safe Empty State. Do this by setting the mark to an impossible value like-1and setting them_codeto a blank string (first char set to null).
void set(const char* code, int mark); Sets the Subjects code and mark to valid values. If the mark is an invalid mark (less than zero or greater than 100) the function will set theSubjectobject to the empty state.
float scale4()const; Returns the Scale 4 (mark out of 4) values of the mark. This function can not modify its owner.
Same as the grade function; see theMarks and their Grades tableto form your selection algorithm to return the proper float value (0.0 -> 4.0)
bool isValid()const; Returns true if the Subject is not in the empty state (ie. mark is greater or equal to zero) . This function can not modify its owner.
void Subject::display()const;
If the subject is valid it will display theSubjectin the following format:
- Subject code in 15 spaces, left justified.
- the mark in 3 spaces, right justified.
- The grade in 10 spaces, right justified.
Otherwise this function will take no action.
The Transcript Class
Private Member Variables (attributes)
The classTranscriptshould have the following member variables:
char* m_studentName; // pointer to hold the student name dynamically Subject* m_subjects; // pointer to hold the subjects in the Transcript dynamically int m_noOfSubjects; // Number of subjects or number of elements in the array of m_subjects. int m_subjectsAdded; // Number of subjects in the m_subjects array that are set to thier values properly (they are not empty)
Private Member functions (Methods)
void setEmpty(); Sets theTranscriptobject to an empty state by settingm_studentNameandm_subjectstonullptr
bool isValid()const; Makes surem_studentNameandm_subjectsare not null and then goes through all theSubjectobjects in them_subjectsarray and makes sure they are all valid. If even one of theSubjects in them_subjectsarray is invalid, this function will return false, otherwise it returns true.
void Title()const; First it will print the Student Name, then in the next line it prints a line using 29 dash('-') characters and then prints a new line:
Fred Soley ----------------------------- float gpa()const; Calculates the GPA by finding the average of theSubjectmarks out of 4.
Find the average by looping throughm_subjectsarray and accumulating the return value of thescale4()functions of theSubjectobjects and dividing them by the number of the elements of the array.
void footer()const; Prints 29 dashes('-') and in the next line on position 22 it will print "GPA: " and then prints the return value of thegpa()function with one digit after the decimal point:
----------------------------- GPA: 3.4
Public Member functions (Methods)
void init(const char* studentName, int noOfSubjects); If any of the arguments are invalid, it will set the Transcript to an empty state (ie.studentNameis null ornoOfSubjectsis less than one)
Otherwise if the incoming arguments are valid:
- init()function will first set them_noOfSubjectsmember variable to the incoming corresponding argument and setsm_subjectsAddedto zero.
- Next it will dynamically allocate memory for the student name inm_studentNameand then copies the name into the allocated memory.
- Then it will dynamically allocate an array ofSubjects pointed bym_subjectsmember variable. The length of this array will bem_noOfSubjects.
Make sure all the dynamically allocatedSubjects are set to empty
bool add(const char* subject_code, int mark); If number of addedSubjects (m_subjectsAdded) is less than the length of them_subjectsarray, this function will set the next available subject to the incoming argument values. Then it will add one to them_subjectsAddedand return true;
Otherwise this function will do nothing, returning false;
void display()const; If theTranscriptis in a valid state, this function will first print thetitle(), then it will loop through them_subjectselements, printing every one of them, and finally prints thefooter(). This function can not modify the Transcript.
Fred Soley ----------------------------- EAC150 65 C DBS211 85 A DCF255 75 B OOP244 95 A WEB222 100 A ----------------------------- GPA: 3.4
If theTranscriptisNOTin a valid state, the function only prints the following line and goes to new line.
Invalid Transcirpt! void deallocate(); Deallocates them_studentNameand them_subjectsarrays and sets the pointers to null.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
