Hi, got a little bit stuck. I am new to programming but I feel this might be the best way to learn.
So I have the following code to count the number of ships
while (true) {
int count = in.nextInt(); // The number of current enemy ships within range
in.nextLine();
if (count == 0) { //If the count is zero, restart from while
continue;
}
However it keeps throwing an input mismatch error (for the count) - this is the same code as the one provided for dist1 and dist2. Why is this not working?
I am assuming this code works like this:
Get next integer input from the scanner (system.input) and 'count' will have a value of that integer. Any tips on where I;'m going wrong would be sweet. (Using Java)