reset password
Author Message
abram92714
Posts: 8
Posted 19:40 Feb 01, 2017 |

did we have to account for whether or not the number in the array was 0 during the reciprocal method. I figure most people simply put 1/(whatever their array name is)[i], but if you do that then your gonna get a runtime error for dividing by 0. (unless dividing by double 0 is different for some reason, i dont remember)

i came up with my solution to continue; my loop if it is zero, but is this something we'll have to keep an eye out for in future labs?? i.e. not explictly stated issues??

Last edited by abram92714 at 19:41 Feb 01, 2017.
nickdrakesi
Posts: 11
Posted 19:49 Feb 01, 2017 |

Hey,

I validated the user's input if they put in 0. 

I usually add extra things in like try-catch exceptions for anything being put in by a user because you cannot trust your user is smart. Its always better to make your code better than what the interviewer/teacher/problem asks for. 

 

 

abram92714
Posts: 8
Posted 23:02 Feb 01, 2017 |
nickdrakesi wrote:

Hey,

I validated the user's input if they put in 0. 

I usually add extra things in like try-catch exceptions for anything being put in by a user because you cannot trust your user is smart. Its always better to make your code better than what the interviewer/teacher/problem asks for. 

 

 

i was thinking to do that to but tbh.... i was to lazy to look up the exact exception name so i just caught the error early and adjusted it and continued the loop before any calculations.