COS1512 Feedback on Assignment 2
Dear COS1512 Student
Your marked Assignment 2 has been released, and you should be able to see the feedback and the
results. Please check the feedback files for feedback on your assignment. The solution to the
assignment has been release a while ago, but I attach an updated version. Please use the updated
version if you want to see what was expected.
Not everyone submitted, which is a pity, since doing the assignments is an important part of
mastering the study material, and also contributes to your year mark, which in turn contributes 20%
to your final mark.
If you have not submitted Assignment 2, please do your best to submit Assignments 3 and 4.
This is a long e-mail/announcement because I provide some general feedback on issues I picked up
while we marked Assignment 2. I will do it question by question. Even if you have not done the
assignment, you should benefit from the feedback. And if you did not do question 8, have a look at
the feedback other students provided for this question. Maybe you can learn something from it.
Question 1
When we overload a function, we have two or more functions with the same name, but a different
number of parameters, or with different types of parameters in the program. Most students could
do this question.
Question 2
The purpose of question 2 was to allow you to practise using the assert() function. If you did not
use the assert() function in your answer, you would not have received full marks for this
question.
I noticed that some students are not clear on how to use non-void functions (i.e. functions that
return values) and reference parameters. If you use a non-void function, e.g. a function with the
following header
double calcDiscount (double price, double discount, bool fixed)
it means that the function must include a statement to return a value, e.g.
return price;
Then the following header
double calcDiscount (double & price, double discount, bool fixed)
would not be appropriate since it would return the modified price through the reference parameter.
On the other hand, if your function is a void function with a reference parameter, such as the header
below
void calcDiscount (double & price, double discount, bool fixed)
modifying the price inside the function would be enough to return the new value for the price.
The header below, however, will not allow the function to return any value to the main program: