Lab 5 Part 1: Structures and Arrays
Due: Tue, March 21, 11:59 pm (this is not meant to be work over the berak. You are expected to complete a good part of it in class on Thu March1)
Write a program that reads student names followed by their test scores. The program should output each student's name, followed by the test score and relevant grade. It should also find and print the highest test score and the name(s) of students having the highest test score. Each student data should be stored in a struct variable of the type StudentType, which has 3 components: name (string), score (int, between 0-100), and grade (char). Assume that the class has no more than 20 students. Ask the user how many students is s/he going to enter. Use an array to store all students (so you need an array of students). Let the user repeat the computations as long as s/he wishes.
The letter grades are assigned as follows:
90-100: A
80-89: B
70-79: C
60-69: D
below 60: F
Finally (after finishing the above tasks), sort the array of students according to the alphabetical ordering of the names, and print out the names (only names) in the sorted order. You can use the sorting program from Chp 7 with modification.
Note: You may encounter the "mixing cin >> variable and getline" problem again. See pages 468-9 for the description and possible solutions to the problem. An easy fix is to use cin.ignore( ) after every cin>> statement in the program.
Requirement | Points |
---|---|
Fulfillment of all requirements listed above | 30 |
Correct sorting of data for all sets of input | 80 |
Complete source code with good formatting, variable names, and comments | 10 |
Total | 120 |