I need help with a little code entry pad.

how do i restrict Y

You use an if statement where by if y is greater than the maximum you want you have a statement to make it the maximum.