CSC133 Introduction to CS Using C++
Lab 11

In this lab you will read student id numbers and lab grades for each student, and calculate the average grade on each lab and the average lab grade for each student. Assume that there will be data for 15 students, with 10 lab grades for each student.

The student id numbers and grades will be stored in a file. The first line of the file will contain the id number of the first student. The second line of the file will contain the lab grades for the first student. The third line will contain the id number of the second student, the fourth line will contain the lab grades for the second student, and so on. Each line of lab grades will be in order (the first number is the grade for the first lab, the second number is the grade for the second lab, and so on). There will be data for 15 students in the file and for each there will be a student id number and 10 grades.

Think about how to store the data in this program. Do you need an array for the grades? Should it be a 1D or 2D array? How will you store the student id numbers?

Your program should read the id numbers and grades and print the id number, lab grades, and average grade for each student. Then the program should calculate and print the average grade for each lab assignment. Make sure you have headings so that the meaning of the numbers in your output is clear.

Use functions in your program. Do not use any global variables.

Sample Input (for three students, you need data for 15 students):

1234
90 80 70 85 95 65 85 95 75 80
2256
70 80 90 85 75 55 85 90 85 70
8642
95 95 90 80 95 80 90 90 75 95

Sample Output (for the three students shown above):

Student ID   Lb1  Lb2  Lb3  Lb4  Lb5  Lb6  Lb7  Lb8  Lb9  Lb10  Avg
   1234      84   80   70   85   95   65   85   95   70    80   80.9
   2256      70   80   90   85   75   55   85   90   85    70   78.5
   8642      91   95   90   80   95   80   90   98   75    95   88.9

Lab    Avg
 1     81.7
 2     85.0
 3     83.3
 4     83.3
 5     88.3
 6     66.7
 7     86.7
 8     94.3
 9     76.7
 10    81.7

Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2002