Validate user input (positive and numerical)
I can't figure out a way to validate user input. The input needs to be both positive and numerical.
So far the code won't accept any letters, but it still accepts negative numbers.
I am a total noob here and the books I have don't seem to cover this. Actually, both books don't seem to cover much of anything I need.
//Get input (minutes and payment) from user
minutesIn = Double.parseDouble(minutesField.getText());
paymentIn = Double.parseDouble(paymentField.getText());
Re: Validate user input (positive and numerical)
So check the values.
Create a validate<whatever those values represent>() method that checks them and returns false if they aren't valid, or even throws an exception.