a
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
a
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 Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
Please edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
If you don't understand my answer, don't ignore it, ask a question.
a
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().
If you don't understand my answer, don't ignore it, ask a question.
It still output the same error after I changed my loop control variable to int
See my edited last post.
If you don't understand my answer, don't ignore it, ask a question.
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.