Aakarsh:
Something like this?:int key=kpd.getKey();
if(key)
{
key=key-0;
key2=(key2*10)+key;
}
How do I do this 4 times?
Perhaps something like that
Did you forget that kpd.getKey(); returns a char and that you have to subtract '0' to get the actual number, not 0, which would do nothing ? You should also check whether what is returned is between '0' and '9' in case the user presses another key.
kpd.getKey();
count how many times you do it and stop when you have done it 4 times.