my code will be display me That is not an acceptable input. if I insert negative number. then proceed to prompt the input. But it continue to calculate. this is part of my code contains something wrong. but i did not see.
public static boolean checkOctal()
{
boolean b = true;
if (oct < 0 && oct > 99999999 )
{
b = false;
System.out.println("That is not an acceptable input.");
}
int tmp;
int tmp1 = oct;
while (tmp1 > 0)
{
tmp = tmp1 % 10;
tmp1 = tmp1 / 10;
if (tmp >= 0 && tmp < 8)
{
continue;
} else
{
b = false;
break;
}
}
return b;
}
you should write
if (oct < 0 || oct > 99999999 )
instead of
if (oct < 0 && oct > 99999999 )
|| stands for or, while && for and.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With