Copy the main template provided in the breakout room activity onto your IDE Add the implementation for the sum_grades(all_categories) function which returns the sum of the weighted average of grades for all categories Program flow

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 9PP: (Data processing) Your professor has asked you to write a C++ program that determines grades at the...
icon
Related questions
Question

 

Instructions

  1. Copy the main template provided in the breakout room activity onto your IDE
  2. Add the implementation for the sum_grades(all_categories) function which returns the sum of the weighted average of grades for all categories

Program flow and computation example

The following example will show you how we compute the final grade for the course from categories with weights and grades for those categories. This is not what needs to be printed out when the user chooses to Compute the grade. This is simply to demonstrate the math behind the computation.

There are 5 categories in this example: PA : 5.0% CA : 15.0% LA : 25.0% QUIZ : 25.0% PROJECT : 25.0% Provided grades: PA grades [100.0, 100.0, 100.0, 100.0, 100.0, 0.0, 95.0] CA grades [100.0, 100.0, 98.0, 95.0, 0.0, 100.0] LA grades [100.0, 100.0, 100.0, 5.0, 0.0, 70.0] Quiz Grades [] Project Grades [] Sum of grades for PA category: 595.00 Sum of grades for CA category: 493.00 Sum of grades for LA category: 375.00 Sum of grades for Quiz Category: 0.00 Sum of grades for Project category: 0.00 Average grade for PA category: 595.00/7 * 0.05 = 4.25 Average grade for CA category: 493.00/6 * 0.15 = 12.32 Average grade for LA category: 375.00/6 * 0.25 = 15.62 Average grade for Quiz category: 0 * 0.25 = 0.00 Average grade for Project category: 0 * 0.25 = 0.00 Total Average grade = 4.25 + 12.32 + 15.62 + 0.00 + 0.00 = 32.20

Pseudo Code for calculating average grade

set overall avg_sum to 0 for category in all_categories: #go through each category list in all_categories set current category grade sum to 0 if len(category) == 2 # if a category only has a name and weight, but no list of grades, # then treat it as not having any grades for that category, # in which case you add 0 to avg_sum and move onto the next category otherwise, for grade in category[2]: #go through the grades list as added in 2nd index of category list add value of grade to category grade sum value add value of ((sum / length of category[2] list) * percentage defined in category[1]) to avg_sum return the avg_sum

In the main program (the grade management system defined in the breakout room lab), add the following lines to prompt the user for computing grade:

elif opt == …: # add the appropriate option key from the menu to compute grades avg_grade = sum_grades(…) #implement this function in the main file to compute average grade print(f"Average Grade is: {avg_grade}")

Example of test sum_grades(all_categories)

all_categories = [ ["PA", 5, [100.0, 100.0, 100.0, 100.0, 100.0, 0.0, 95.0]], ["CA", 15, [100.0, 100.0, 98.0, 95.0, 0.0, 100.0]], ["LA", 25, [100.0, 100.0, 100.0, 5.0, 0.0, 70.0]], ["Quiz", 25, []], ["Project", 25, []] ] assert sum_grades(all_categories) == 32.20 all_categories = [] assert sum_grades(all_categories) == 0.00 all_categories = [["PA", 5, [100.0, 100.0, 100.0, 100.0, 100.0, 0.0, 95.0]]] assert sum_grades(all_categories) == 4.25

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Form
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT