Start by converting the strings to numbers:
string input = "38";
int value;
if (!int.TryParse(input, out value))
{
... bad value: tell the user it's not a number! ...
return;
}
// From here, you can use value as a number.
Now you have it as a number, you can decide how many to the nearest 10. That's pretty easy: if you use the modulus operator "%" it will return the remainder of a division. So 38 modulus 10 will return just the "lowest digit": 8. You can then use
if
to check if you want to go up to 40 and return
10 - n
or down to 30 and return
n