Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
Members have full access to the forums. Advertisements are removed for registered users.
Why use a double for the loop control variable?
Can you copy the contents of the console window that shows the problem and paste it here?
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Please edit your post and wrap your code with
<YOUR CODE HERE>
to get highlighting and preserve formatting.
That's the Scanner leaving a linenend character in its buffer after the call to nextDouble().
Call nextLine() to clear the lineend character after the call to nextDouble().
It still output the same error after I changed my loop control variable to int
See my edited last post.
Sorry, I read it but it is not very clear to me.
--- Update ---
Thank you very much. I figured it out, so sorry for any inconvenience.