Encouraging you (and showing you how) to think through solving this yourself.
Problem statement: It (the second loop) works the first time but when it comes to that point again after looping it...
Type: Posts; User: GregBrannon
Encouraging you (and showing you how) to think through solving this yourself.
Problem statement: It (the second loop) works the first time but when it comes to that point again after looping it...
You're being a bit dense. I told you that a nextLine() was required after collecting numeric input because nextInt(), nextDouble(), etc. leave a linefeed in the input buffer. In the case shown,...
Because of this:
paid = scan.nextLine();
scan.nextLine();
The nextLine() method will wait until the buffer contains a linefeed. You have two of them in a row, so two <returns> are required.
If you're asking for help by this statement, please post your latest code, and, as appropriate, a sample run that shows problems/undesirable behavior, current issues, specific questions, and any...
Again, take a breath, read the error, look at the code it is pointing at, and take a moment to think.
A few thoughts should occur to you: '=' is the assignment operator, '==' is the comparison...
You need to think these things through a bit more and thoughtfully TRY things. You're getting frustrated and giving up too early.
Your current construction is:
if ( yes )
if ( no )
else...
if ( thisString.equals( thatString ) )
Are you using the comparison operator, '==', instead of the equals() method to compare Strings?
Essentially, yes. If you've gotten the desired data, as in:
double neededData = input.nextDouble();
you can "flush the buffer" immediately afterwards with
input.nextLine();
If there are...
Scanning for a specific token, usually a numeric value like int, double, etc., does not capture and clear the linefeed character in the input buffer. If that Scanner statement is followed by one...
Welcome to the Forum! Please read this topic to learn how to post your code correctly along with other useful info for newcomers.