0% found this document useful (0 votes)
2 views

Practice Problem on Classes

The document outlines a practice problem for a C++ class named tGradeType, which is designed to manage three test grades for students. It specifies data members and member functions for getting and setting grades, calculating averages, and initializing grades. Additionally, it includes requirements for a client program that tracks grades for four students and demonstrates functionality through sample outputs.

Uploaded by

Brandon Tseng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Practice Problem on Classes

The document outlines a practice problem for a C++ class named tGradeType, which is designed to manage three test grades for students. It specifies data members and member functions for getting and setting grades, calculating averages, and initializing grades. Additionally, it includes requirements for a client program that tracks grades for four students and demonstrates functionality through sample outputs.

Uploaded by

Brandon Tseng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSCI 2380 Spring 2025 Mr.

Dietrich

Practice problem on C++ classes

Define a class named tGradeType to keep track of the three test grades (whole numbers) that
a student can get in a semester according to the following rules:

Data member (instance variable):

1) An int array named tgrades size 3: stores the three test grades

Member functions (methods):

1) getGrades(first, second, final): returns the three tests grades stored in tgrades array.
2) setGrades(first, second, final): stores the tests grades in tgrades array.
3) avgGrade(): returns the average of the three tests as a whole number.
4) default constructor: initializes all test grades to 0.
5) parameterized constructor: initializes all test grades to the values specified by the client
program.

Client program:

1) Keep track of 4 students' test grades.


2) Initialize the grades of the first two students to 0,0,0 and the grades of the next two to
95, 70, and 100
3) Show the average test grade for each student
4) Change the grades of the first two to any values that you like (0..100)
5) Show the first student test grades followed by his new average
6) Show the second student test grades followed by her new average

Feel free to add more members (data and/or functions) to the class if you like (for example full
name, comparison of average grades, etc.) and/or more method calls in the client program.

Watch the videos about designing, creating, and using a class before you write your
program.

First, create the class diagram.

Next, use pseudocode to describe what the member functions and main() must do.
CSCI 2380 Spring 2025 Mr. Dietrich

Finally, implement your solution using C++.

I am providing you my sample solution so you can use it as a reference regarding how your
program should behave.

Sample run of my program.

You might also like