Assignment #1 Task #6

Please note, this blog entry is from a previous course. You might want to check out the current one.

If the user performs an operation for which he or she has not entered enough operands, use zero as the missing operand(s) (the code from the walkthrough does this already, so there is nothing to do for this task, it is just a clarification of what is required). Protect against invalid operands though (e.g. divide by zero).

As performOperation returns only numbers for the moment we just return 0 for a division through zero or square roots of negative numbers e.g.:

if (!divisor) return 0;
if (number < 0) return 0;

Leave a Reply

Your email address will not be published.