Um, I'm new here, and new to programming in general. But I am working out of Absolute Java too, and just did this problem.
I haven't run your code, but just at a glance, there seem to be some problems.
(Or, perhaps I am mistaken. See for yourself. I'll just let you know what I'm thinking here.)
First, by the way you've structured it, it would not seem to allow you to discover MULTIPLE solutions to the problem. You tell the system to exit when a solution is reached, don't you? Or am I misunderstanding?
Second, you tell the program to "continue" if a solution is encountered where two of the variables correspond to the same numeral, but you don't tell the program NOT TO COUNT those solutions, which - I think - is what the programming problem requested.
Third, I'm not even sure what role "keep going" is playing. The nesting of the loops ensures - I think - that all possibilities/permutations are realized/considered by that point in the coding, does it not? So what is the point of the Boolean condition there?
I hold out the possibility that I am way off base in all of this. I have only been programming for 3 weeks. But here is my code (sorry so sloppy).
(Also, you'll see I threw a 'counter' in there to tally the combination/assignments that failed. But in this too I might be confused. Again, sorry if my comments are way off here.)
public static void main(String[] args) {
int count = 0;
for (int G = 0; G <=9; G++)
{
for (int O = 0; O <=9; O++)
for (int T = 0; T <=9; T++)
for (int D = 0; D <=9; D++)
if (((G != O) && (G != T) && (G != D) &&
(O != T) && (O != D) && (T != D))
&&
((400 *T) + (40 * O) + (4*O)) ==
((1000*G) + (100*O) + (10*O) + (1*D)))
{
System.out.println("G = " + G + "," + " O = " + O + "," +
"T = " + T + "," + "D = " + D);
}
else count = count +1;
}
System.out.println(count);