Problem 175
Sorting Records on Two Fields
Make a record to store information about a student’s grades. It should contain fields for:
- the student, which is identified by a three-digit integer for their “student id number”
- the grade number, which is an integer (1-6)
- the grade, which is a floating-point value (0.0 through 100.0)
- the corresponding letter grade, which should be a String
I have provided a file filled with grade information. You should create an array of records with 30 slots. Read the contents of the file into the array of records.
Required files: gb.txt
Then, rearrange the array so that grades are sorted by grade number within student and display the sorted contents.
Open which file: gb.txt Data loaded. Data sorted. Here are the sorted grades: 171 1 47 F 171 2 64 D 171 3 86 B 171 4 26 F 171 5 78 C 171 6 70 C 679 1 32 F 679 2 41 F 679 3 29 F 679 4 21 F 679 5 32 F 679 6 70 F 819 1 53 F 819 2 70 C 819 3 66 D 819 4 73 C 819 5 43 F 819 6 37 F 884 1 57 F 884 2 81 B 884 3 35 F 884 4 44 F 884 5 38 F 884 6 34 F 938 1 57 F 938 2 65 D 938 3 53 F 938 4 28 F 938 5 52 F 938 6 43 F
◄ 174: Sorting Strings 225: Constructors ►
Adapted from ProgrammingByDoing.com
©2013 Graham Mitchell
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.