Trying to code in hasNextInt() for data type checking. Basicall my code ask user for input and if user doesn't use an int they get an error. I know i should have a if and else statement with this.
I am trying this data type checking in this block of code and I get tons of errors
while (isValid==false )
}
System.out.prin t("How many Hammers? ");
if(input.hasNex tInt())
{
numHammers = input.NextInt() ;
isValid = true;
}
else
}
input.nextLine( );
System.out.prin tln("\nError! Please enter a number!");
}
}
I am trying this data type checking in this block of code and I get tons of errors
while (isValid==false )
}
System.out.prin t("How many Hammers? ");
if(input.hasNex tInt())
{
numHammers = input.NextInt() ;
isValid = true;
}
else
}
input.nextLine( );
System.out.prin tln("\nError! Please enter a number!");
}
}
Comment