0

need help with code

In C++ Given the following class definition: class Student { private: int studid; char name[20]; float g1,g2,g3; public: Student(int num, char * n,floatgr1,float gr2,float gr3); Student(); void compute_average(); }; The first constructor will receive 5 arguments that will be used to initialize the instance variables.The second constructor will not receive any argument and initialize g1 as 100, g2 as 50 and g3 as 80. Create the constructors and method definitions and create 2 objects of the Student class within the main. The first object should be created using the first constructor and the second object using the second constructor. Also call the compute_average method to calculate the average grade for each student. Print all the information of each student along with its average.

29th Nov 2017, 2:55 PM
Trever Young
Trever Young - avatar
1 Answer
0
It might be too late, but here you go: https://code.sololearn.com/cfisbTJ7swR9/#cpp I made a couple changes to the names of the variables and in particular I change the 'char' array to a 'char' pointer. I also included some mutator and accessor functions in order to read and write student information. The return type of the average method is no longer void, as it returns the average grade of the student. If you have any questions, let me know at terrestrial.primate@gmail.com
2nd Aug 2018, 11:21 PM
Louie
Louie  - avatar