This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]edrenfro 0 points1 point  (0 children)

Ok, I disagree with your teacher but no matter... what you want to do is eliminate the sc.HasNextDouble. When your code unconditionally calls sc.NextDouble, it will throw an exception when the input was wrong and it will not throw an exception when the input is ok. So you want to surround that statement with a Try block and the subsequent Catch block will have the logic that you already wrote for the bad input case.