0
If statement java
So I want to do an if statement and I am expecting a number above 1. I want to make it so that if someone inputs 0/a letter/word if gives them a msg saying they must enter a number that's not zero. And I want the float to be called valA. How do I code it?
2 odpowiedzi
0
thank you
- 1
if (valA == (int)valA) //TESTING IF valA is an integer
{
valA = Integer.parse... //CONVERT YOUR STRING TO INTEGER ...
if(valA>1)
{
// HERE valA is above 1
} else {
//SOME CODE THAT SAYS : INT SHOULD BE > 1
}
} else {
//SOME CODE THAT SAYS : ENTER AN INT PLEASE
}