Question: There is very little difference between a struct and a class. The major difference is that by default, the members of a struct are public

There is very little difference between a struct and a class. The major difference is that by default, the members of a struct are public while the members of a class are private. In this exercise, you will convert a struct to a class. Here is the struct, called studentType:

struct studentType 
{ 
 string firstName; 
 string lastName; 
 char courseGrade; 
 int testScore; 
 int programmingScore; 
 double GPA; 
}; 

Your class should have the same components as the studentType struct. Assume that the test and programming scores are restricted to the range 0 - 100, inclusive and the GPA is restricted to the range 0 - 4.0, inclusive. Assume that the courseGrade is the average of testScore and programmingScore scaled to a letter grade on a 10 point scale as follows:

90 - 100 is an A

80 - 89 is a B

70 - 79 is a C

60 - 69 is a D

lower than 60 is an F

You are to add member functions to manipulate the data members. Follow the convention that the instance variables are private and the member functions are public. First, create a UML diagram for your class. Second, write the header file including documentation for the function prototypes specifying the purpose of the function, any preconditions that may exist, and the postconditions. The viewpoint of the documentation is for someone who might want to use your class. Write the implementation file. Make sure any data provided to modifier functions does not violate the preconditions and that the private instance variables do not become invalid. Write a test program to show that the class is working as specified..

Turn in your UML diagram, studentType.h, studentType.cpp, and test program files. Also turn in one or more screen shots showing the results of your testing.

Once this exercise is completed, you will demonstrate that you are able to:

Construct a UML diagram

Write a class header and implemention file in C++

Specify preconditions and postconditions for the member functions in the header file

Translate preconditions to code which maintains the validity of the private variables

Write a program that demonstrates that your class is working as specified

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!