educative.io

Wrong return value for getMarks()

In the template of the exercise the method getMarks() is defined as:

int GetMarks(int marknumber)

However the method returns the value of members mark1 or mark2 which are float. I would expect the return value of the method should also be float, not int.


Course: Educative: Interactive Courses for Software Developers
Lesson: Educative: Interactive Courses for Software Developers

Hey, @NJ_van_den_Berg!

You said that you’re expecting the float data type instead of an int.The following statement is written in the lesson:
Get_Marks(int marknumber), a function which should return mark1 if marknumber equals 1 and mark2 otherwise.

But the function was also working fine, even for the int data type. I have checked and made a small modification in the code in order to pass the test only if the float data type has been used in the implementation. I have also updated the Solution section.

Thanks for pointing this out. We hope Educative has inspired you to further your learning. Thank you!