CJCoding With Joseph
15free / daySign inCreate account

University of Lethbridge - CPSC

Lab 8 Breakdown

Labs

This guide contains everything you need to fully understand and follow the code being created in Lab 8.


Assignment Summary

You’re reading a file called GPA.txt that contains student names and GPAs.

You’ll:

  1. Store each student in a struct.

  2. Use an array of those structs (up to 50 students).

  3. Read from the file and populate the array.

  4. Sort the array by GPA.

  5. Display the min and max GPA (with names).

  6. Calculate and show the average GPA.


Breakdown of What You’ll Do

Step 1: Define the student struct

Step 2: Create the obtainNamesAndGPAs function

  • Reads the file GPA.txt

  • Fills the array of students

  • Updates the number of students (by reference)

Step 3: Create the sortGPA function

  • Sorts the array by GPA using simple bubble sort

Step 4: Create the displayMinMaxGPA function

  • Finds the min and max GPA

  • Prints their names (handles ties)

Step 5: Create the calcAvgGPA function

  • Loops through all GPAs

  • Returns the average

Step 6: Main function

  • Calls all the above in order

  • Displays final sorted list, min/max, and average

Members only

Keep reading this lesson

You've reached the end of the free preview. Unlock the rest of this lesson plus 27 more lessons in University of Lethbridge - CPSC.

  • Unlimited coding questions
  • Unlimited access to all classroom material
  • Weekly live call for questions and guidance
  • 3,000 AI tutor tokens / month
  • Personal SQL database (3 MB)
  • Progress tracking

Cancel any time.