-3
        while (done = false)
        {
        if (((int1 / int2) >= 1.0) && ((int1 / int3) >= 1.0))
        {
            System.out.println(outputInt1 + " ");
            int1 = 0.1;
        }
        if (((int2 / int1) >= 1.0) && ((int2 / int3) >= 1.0))
        {
            System.out.println(outputInt2 + " ");
            int2 = 0.1;
        }
        if (((int3 / int1) >= 1.0) && ((int3 / int2) >= 1.0))
        {
            System.out.println(outputInt3 + " ");
            int3 = 0.1;
        }
        else if ((int1 == 0.1) && (int2 == 0.1) && (int3 == 0.1))
        {
            done = true;
        }
        }

Hi, I can't seem to be able to figure out why this while statement will not run. In the console it simply will not print anything in the if statements.

I assume it's an error with my arithmetic in the if condition.

Thanks!

rgettman
  • 176,041
  • 30
  • 275
  • 357

1 Answers1

1

Change it to while(done == false). :) Or, even better, while(!done). What while(done = false) does is the following:

  1. First, set done to false
  2. Evaluate done to check if the while loop should execute.
  3. See that done is false, so don't execute.
Avi
  • 2,611
  • 1
  • 14
  • 26
  • It evaluates the result of the assignment expression. Assignment returns a value. So, `done = false` will set `done` to `false`, and return the new value of `done`, which is `false`. In that sense, it won't re-evaluate `done`, it'll just return the value of `done` *if* you were to re-evaluate it. – Avi Sep 24 '19 at 21:39
  • completely missed that, thanks! – Edgar Jaden Sep 24 '19 at 21:56