0
Why is it not throwing exceptions when I enter Zeros? Help me correct the mistake
Write a program that prompts the user to enter a length in feet and inches and outputs the equivalent length in centimetres. If the user enters a negative number or a nondigital number, throw and handle an appropriate exception and prompt the user to enter another set of numbers. https://code.sololearn.com/cgTP3EAT7p9o/?ref=app
11 Respostas
+ 4
You have written && inches, that is the problem.
Because this means: If feet<=0 AND inches !=0.
So if you enter 0 for feet and something for inches, you do get your error.
But if both are zero, you don't get the error.
For clarity, once again:
if(inches)
means the same as:
if(inches != 0)
+ 1
Cheers thanks
+ 1
Ruchika Tripathi honest how is this song related to my question ❓
0
Are negative numbers digital numbers?
0
I'm still failing to correct it. Please help me.
0
~ swim ~ can you kindly give me an outline of the code you're talking about. I'm completely lost. Please
0
~ swim ~ it is not throwing an exception of one 0 is put plus a positive number but if both zeros are put. It is not throwing the exception