Solved

The Following Example Shows How a Programmer Might Avoid a Division

Question 9

Essay

The following example shows how a programmer might avoid a division by zero error by explicitly checking for the error condition:
if(gallonsOfGas != 0)
mpg = milesDriven /gallonsOfGas;
else
mpg = 0;
Another possible way to deal with this is to use exception handling mechanisms.What factors help the programmer decide which of these methods to use?

Correct Answer:

verifed

Verified

The example code represents the most eff...

View Answer

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions