Create an enumerated type that has the class levels as its


Assignment

College maintains a file of credit hours completed for their students, named CREDITS.TXT. Each line of the file contains:

• the student's ID number (an 8-character string, containing 2 letters followed by 6 digits)

• the student's status (an character: U for undergraduate, G for graduate, A for alumni)

• the student's number of completed credits on each line.

Example:

CC333333 U 3

AA111111 G 36

BB222222 U 80

DD444444 U 52

CD334455 U 100

BC223344 U 10

AB112233 A 134

EE555555 G 18

DE445566 U 122

The college would like you to write a program to convert the number of completed credits for all Undergraduate students to class levels, and to make the data searchable by student ID number.

The college uses the following completed credit ranges to determine the class levels:

Credits Completed Class Level:

Under 32 Freshman

32 - 63 Sophomore

64 - 95 Junior

Over 95 Senior

Create an enumerated type that has the class levels as its values, in the order given, so that the ordinal value of FRESHMAN will be 0, and the ordinal value of SENIOR will be 3.

Program Implementation

The program will do the following:

1. Display a short description of what the program will do to the user.

2. Verify the input data file exists. If it does not exist, issue an error message and exit the program immediately.

3. Read the data from the input file. For each line of data read: If the student is an undergraduate student

• Call a function to convert the credits completed to a class level

• Store student data into two separate parallel arrays.

• (NOTE: Even if you know how, you may not use an array of records!)

The first array will hold the string-type student ID number. The second array will hold the corresponding class level of the student.

You must store the enumerated type value in the second array, not the ordinal integer value.

Since the program will only be storing data for undergraduate students, if the student is not an undergraduate student, the student ID or class level will not be saved anywhere.

The arrays will be defined to hold up to 1000 items each. You can use the same count variable for both arrays, since they will always hold the same number of items.

Your code must implement array bounds error checking.

So if the file contains too many lines of data:

• Issue an error message

• Stop reading data from the file.

• Continue the program with the 1000 records in the arrays.

NOTE: The program should not issue an error message if the file contains exactly 1000 undergraduate students - only if it contains more than 1000 undergraduate students.

4. Use the selection sort to sort both parallel arrays in descending order, based on the student ID number. Remember that strings in arrays can be compared the same way that numbers can, using the less than and greater than operators.

Example: if ( studentId[oneIndex] < studentId[anotherIndex] )

NOTE: All the sample code shown in the week-by-week and in the textbook sorted in ascending (low to high) order. You will need to modify the code so that it sorts in descending (high to low) order.

5. Write the data from the sorted arrays out into another file, SORTED.TXT. This file should store one student ID and one corresponding class level per line. Sample SORTED.TXT data file (corresponding to sample input data file):

Example

DE445566 3

DD444444 1

CD334455 3

CC333333 0

BC223344 0

BB222222 2

Note that the ordinal value of the credit rating enumerated type is stored in the data file. This enables the program to simply write the data to the file from the enumerated type field, with no conversion.

6. After sorting and storing the data, loop to display the class level for specified students, as follows:

a) First display all student ID numbers in the array (horizontally, with 5 IDs per line), so the user can see his/her choices.

b) Then prompt the user for a student ID number (or X to exit the program).

Sample Output:

Student ID numbers on file are: DE445566 DD444444 CD334455 CC333333 BC223344 BB222222 Enter ID number of student to find (or X to exit):

c) After reading the student ID entered by the user, and before the program searches for the student, the program should error check that the user entered ID number is ***** correctly (i.e. 2 letters followed by 6 digits).

NOTE: Error checking of the characters in the student ID number should be done using loops, not by using brute force to check each individual character. Remember that you can access the individual characters within a string, as if the string was an array of characters.

For example: inputIdNumber[0] could be used to access the first character in the student ID number input by the user.

The program is due Thursday. Here is some more information you may need

HINT: For each index, use the position index to determine whether the character should be a letter or digit. Then use a character function from the cctype library to check for a letter, if it should be a letter or to check for a digit if it should be a digit.

If an invalid student ID number format is entered, give a descriptive error message explaining the correct format, and re-prompt until a good student ID number is *****

Examples: Input AA3333333 is too long. ID must be exactly 8 characters long. OR Input 3A333333 letters and digits are not in the right places ID must be exactly 8 characters long, formatted as: XX######

NOTE: The letters may be entered in either upper or lowercase, but the program should uppercase them before using them to search in the next step.

d) Use the student ID number with a binary search to find the student requested. If found, display the corresponding class level (in words) for the specified student. If not found, display an appropriate error message.

Examples: The student with ID DD444444 is a sophomore. OR No student with ID WW888888 was found.

NOTES:

Again, the binary search examples in the online Content assumed an ordered array sorted in ascending order. You must modify the search for use with arrays that are sorted in descending order.

You will need to write code to convert the enumerated class level value to a string, for display.

e) Loop displaying student ID choices, asking for an ID number, and displaying the student's class level, until the user enters "X" (or "x") to exit the program, at the student ID prompt.

You will turn in a structure chart for this program, along with the code. Your structure chart should contain one rectangle for each function in your program and include all data values passed into/out of each function (see online Content section 2.6.1 through 2.6.3 for structure chart details).

Notes

1. All fixed values within the program should be defined as constants.

2. Descriptive function, constant, and variable names must be used.

3. Your program must conform to the CS362 Coding Standards specified in Content section 1.7. As such, the program must include a file header comment block at the top of the program, and each function must include a function header comment block.

4. This program should be of modular design (minimum of SIX user-defined functions that have arguments or return values), and use proper parameter passing and prototypes.

The breakdown of the code into functions must be logical, not arbitrary!

The main function should do little more than call other functions.
The other functions should each perform ONE well-defined task.

5. All code will be structured C++ code. Object-oriented programming (classes, templates, etc) will not be used.

6. Your program should be thoroughly tested, and test data files should be submitted.

is not adequately modular (i.e. contains fewer than the required number of functions)

does not include a structure chart with the submission Before attaching files to the assignment submission.

Solution Preview :

Prepared by a verified Expert
Programming Languages: Create an enumerated type that has the class levels as its
Reference No:- TGS01726989

Now Priced at $40 (50% Discount)

Recommended (97%)

Rated (4.9/5)