It would be useful if you made the test program and worked with it to learn how to use indexOf and substring. The posted code does not show what is in the String s or print out the value of space or...
Type: Posts; User: Norm
It would be useful if you made the test program and worked with it to learn how to use indexOf and substring. The posted code does not show what is in the String s or print out the value of space or...
Did you try the test program I suggested?
That is how I check out new classes and methods - write a small test print and print out the results.
What is in the String: height? What is the value in space?
Print them out so you can see what their values are.
I suggest that you write a small test program with these 5 lines:
Define a String...
"Exception in thread "main" java.lang.NumberFormatException: For input string: "59 1.72"
That looks like the original problem.
Did you use substring to get the two numbers from the input...
Does it work now?
If not, please post any further questions or problems.
Ok. To use substring you need to know what columns to access. Did he say how to determine what columns to use with the substring method?
There are several useful methods in the String class:...
Another option - have the user only enter one number at a time.
Otherwise describe how your instructor expects the program to get the user's input.
The String passed to the parseDouble method is not a valid double value. It looks like there are two values there separated by a space.
To get at the separate values in the String, read the user's...