Hi guys,
I've created an if statement which produces these outputs....
if you enter 0, you get an output of +"zero"+.
if you enter any number over 0, you get an output of +"numeric"+.
if you enter a non-numeric character, you get an output of +"non-numeric"+.
It works when i enter in numeric characters, but when i enter in a non-numeric character, like h, i get a "Error: cannot find symbol - variabal h" on the object. I've written it in brackets and it still won't work.
Can anyone give me hint where i'm going wrong?
Here's my code...
public class Numbers
{
private char c;
/**
* Constructor for objects of class Numbers
*/
public Numbers()
{
// initialise instance variables
char c = 1;
}
/**
* Enter value...
*/
public void getValue(char c)
{
if(c < 1) {
System.out.println("Zero");
}
else if (c >= 1) {
System.out.println("Number");
}
else {
System.out.println("Non-numeric");
}
}
}