I'm writing a program that returns true if and only if the input are numbers and contain one decimal, e.i. (8.3). Also it cannot contain space in between the numbers, e.i. (8 8) would return false. Leading and trailing space are okay, e.i ( 8888 ). I'm stuck on finding white space in between the input, how do I got about doing it? I'm thinking about using Arrays, but not sure how to set it up.
No. RE is overkill. (And not acceptable for HW assignments.)
Just count the number of digits in the string. It should be equal to the length of the string minus one. Then check to see if the string contains a decimal point ('.'). If it does, then the string is validated. In any other case, the string fails.
Thanks for your help guys, the following is the function I have. It works as I need to. The only thing I'm missing/having problems is how to go about finding if I have any spaces in between my numbers.