So new to the whole Java shindig thats going on over here, I am 1 month down in my 4 year software engineering degree, And I am already stumped on how to pull doubles from a string using a Scanner. The code is a mess, and I'm sure it doesn't make much scene but working on one problem at a time,
Any point in the right direction would be amazing!
Where are you initialising tempNum? Why are you using two Scanners? You only need one. Don't use nextLine() if you want a number, use nextXXX(). Don't pass the result from one Scanner to another, which is unnecessary.
You can enter several doubles and read them in a loop, like this
Enter your numbers: 1.23 2.34 3.45
Enter more numbers, or "close" to finish: 4.56 5.67 close
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop