Structure and classes C++
Objective
The purpose of this lab project is to expose you to structures and classes.
Problem Specification:
Using a structure:
You are to write a program that will define a structure consisting of the following data members, “fields”:
- Name - a string
- Student id number – an integer.
- Three test scores – positive short integers.
- Average –a float
- Grade – a character.
Input to the program consists of:
- name
- id number
- three test scores
Requirements:
Use a function to read the name, id number and three test scores, the function will return a structure.
A function to find the average, the function is a void function that takes the entire structure as an argument (by reference) and calculates the average.
A function that takes the average as argument and returns the grade (‘A’,’B’,’C’,’D’, or ’F’) using standard grading.
A function that prints each data member of the structure on a separate line and calls another function that prints the message “You Passed” or “You Failed”.
Using a class:
You are to write a program that will define a class consisting of the following data members:
- Name - a string
- Student id number – an integer.
- Three test scores - short integers.
Input to the program consists of:
- name
- id number
- three test scores
Requirements:
Must use a project with three files (a specification, an implementation, and a client file)
Must define a null destructor, and a constructor with default arguments to initialize data members to null or zero.
Use a setter function to read the name, id number and three test scores from the keyboard.
A getter function that prints each data member of the object on a separate line and uses two private functions that will find the average and grade (local to print) to be printed. Print will also print “You Passed” or “You Failed”.
All getter functions are constant with constant parameters.
Your output, for both, should be a report like follows:
Employee Name : Jim Donavan
Id Number : 2345
Tests :
78
88
98
Average : 88.00
Grade : B You Passed.
Grading criteria:
Structure implementation
5 points Good programming practices: Proper spacing, comments, use of descriptive variables, indentation and appearance of program.
5 points typedef is used to define a structure and the new type is used where needed.
5 points every function has specifications.
5 points Hierarchical chart is handed-in and is correct.
25 points Requirements above are followed.
5 points test results are handed in.
Class Implementation
5 points project has three files
3 points Guards are included.
2 points destructor function is defined as requested.
5 points constructor functions is defined as requested.
5 points every function has specifications.
5 points class diagram including access specifiers is handed-in and is correct.
20 points Requirements above are followed.
5 points test results are handed in.
Submission Details:
Submit a print-out of:
The source files
A hierarchical chart
A class diagram
A test run for each.