This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Well, it depends on you how you plug those loop holes that can cause you application to fail, you cannot expect user to enter only definite set of values when there is not restriction. User intentionally or unintentionally can enter any figure, its up to you how you handle it.
In the example mentioned, you can even match whether its a number or not before parsing it.