Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

all the information is provided below. only the .h file is needed Given a class Student: - Declare the following class' data members: (1) Public

all the information is provided below. only the .h file is needed

image text in transcribedimage text in transcribedimage text in transcribed
Given a class Student: - Declare the following class' data members: (1) Public data member name (string datatype) (2) Public data member grades is an unordered_map that maps string course names to oat scores. For example: grades["COP3523\"] = 755. . Initialize the variables by implementing a parameterized constructor. Keep all the data, members, and member functions public. - Complete member function named getAverage() of class Student that computes and returns the average of scores of the student Note: The average score for a student is computed by adding the scores corresponding to each course, divided by the total number of courses In addition: The average would be zero in case there are no grades - Complete the member function modifyGrades() that takes in a function pointer as a parameter and uses this function pointer to modify the value of each grade in the map. This function does not return anything. The function being pointed by this pointer takes a oat as a parameter and returns oat. 3 [Hint 1: lterate onto each value of the map and use the function pointer passed by the user to modify the value on the map] File is marked as read only Current file: main.cpp 1 #include 2 #include "Question4.h" 3 using namespace std; D 5 static float square(float n) { 6 return n*n; 7 8 9 int main( ) { 10 // This is just for demo purposes. Your code will be tested against dynamic unit test cases. 11 unordered_map grades; 12 grades [ "course1"] = 2.0; 13 grades [ "course2"] = 20.0; 14 grades [ "course3"] = 20.0; 15 grades [ "course4"] = 30.0; 16 grades [ "course5" ] = 3.0; 17 int type; 18 cin >> type; 19 Student s("abc", grades) ; 20 if (type = = 1) { 21 cout W N #include 4 #include 5 using namespace std; 6 7 class Student 8 { 9 public: 10 // TODO: Declare the publis members of the class per instructions 11 string name; 12 float grades ; 13 // TODO: Define a paramterized constructor 14 Student: : Student (string name, float grades) { 15 name = name ; 16 grades = grades; 17 18 / / TODO: Implement the getAverage() with return type float 19 20 // TODO: Complete the implementation of modifyGrades( ) which uses a function pointer (given as an input paramter) 21 // to change the value of each grade (return type - void). Refer to problem statement for more clarity. 22 23 }; 24

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions