input += k.getkeyChar();
where input is of type String. You can't perform arithmetic on two Strings.
You must convert the values to a numeric type such as int, float, or double.
Here's a short example:
The key lines that you should study are these:
try{
output = Integer.parseInt(input);
}catch(NumberFormatException nfe){
output = -555; //error code
}
This is an example of exception handling. The Integer.parseInt method throws
an exception if it is fed a String value which does not parse into an
integer. So, we, as programmers, must handle the situation where a user may
enter bad data and the try-catch construct helps us with this. You will
notice that anytime a user enters bad input the value of output (an int
variable) will be set to -555.