Write a piece of code that, given an array a of integers, computes the average of all positive elements of this array. Elements can be 0 but they should not be negative. Make sure that an appropriate exception is raised if one of the values is negative and that the corresponding error message is printed.
For extra credit: generate an additional exception (and the corresponding error message) in the situation when the array only has zeros. Warning: extra credit will be only given if the main assignment works correctly.