This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!
See welcome thread
Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!

Carey Brown

Saloon Keeper
+ Follow
since Nov 19, 2001
Carey likes ...
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
Forum Moderator
Carey Brown currently moderates these forums:
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Carey Brown

Have you tried it?
2 days ago
Then it's just like reading any text file.
2 days ago
Typically a file ending in '.sql' is a plain text database program written in SQL. So, are you wanting to read in the plain text of the file, or are you trying to run the file as a database program and capture its output?
2 days ago
This is a classic error and is why writing this is a no-no.
You meant to say
but as you found out, if you mistakenly leave out one of the '=' then the behavior changes entirely.
You should instead use
3 days ago
To compare all possible combinations of pts rows you'll need to revise this loop. Note that distance(A,B) is the same as distance(B,A), so don't test the same combination of rows.
3 days ago
You can do away with all your temp variables, pts[n] returns an array of three elements (x,y,z). So, you'd end up with
Like wise for the code in your loop.
3 days ago
You are correct, but if letterInput = a then charAt(1) will throw an exception.
3 days ago
You have a potential problem with these lines
If the user just presses Enter with no characters then the charAt(0) will throw an exception. Likewise, if only a single character is entered the charAt(1) will throw an exception. You'll want to check that letterInput.length() == 2 to take some preventative steps. Also, you may want to change the prompt to let the user know not to put a space between the two characters.
3 days ago
Line 93
You should stick with using scan.nextLine() and stay away from accessing by two different means.
An ASCII 'a' has a numeric value of 97 (decimal). 'f' is 102. A space is 32. So therefore your code would translate to
On line 1, choiceOne can never be greater-or-equal to 97 AND at the same time be less-than-or-equal to 32.

To see if your chars ARE NOT in the range of 'a' through 'f'

Your println("\f"); is also a problem. If you want to output a blank line use

3 days ago
'i' goes from 1 to rows-1. The pts array has rows 0 to rows-1. On line 31 you are adding 1 to the row so that would be 2 to rows. The index must be less than 'rows' so you exceed the limit.
3 days ago
Please post your modified code (with indents cleaned up).
3 days ago
One often used approach where user input is required is to put the validation check and loop inside a method. Something like
Then in the main body of your code you can call it like:
And remove all your validation from your main body. Much cleaner.
3 days ago
On line 19 add
Line 23
Line 92, do away with the else.

I would strongly urge you to clean up your indentation.

Putting some of your logic into their own methods would help make the code clearer.

You'll only ever need one scanner for keyboard so you can create it as a class static constant.
3 days ago
Set up an array of constants
and use that in a loop with the same algorithm that you're currently using.
3 days ago
Please give more detail about your problem. What output were you expecting, and what output did you get? Did you get any error messages? If so, post the complete error message.
3 days ago