while(tryAgain = true)
= is assignment, to test for equals use ==
but in this case, since tryAgain is already a boolean (true or false) yu can just say
while (tryAgain)
JamesCherrill
... trying to help
8,667 posts since Apr 2008
Reputation Points: 2,636
Solved Threads: 1,476
Skill Endorsements: 33
That's because the compiler has seen that the two if tests on lines 16 and 20 could both be false, in which case neither of the assignments on lines 18 and 22 will be executed, and the tryAgain variable will not have been initialised by you.
You need to decide what the correct value of tryAgain should be if both if tests fail, and initialise tryAgain to that value when you declare it, eg by changing line17 to boolean tryAgain = true;
JamesCherrill
... trying to help
8,667 posts since Apr 2008
Reputation Points: 2,636
Solved Threads: 1,476
Skill Endorsements: 33
@angel-do as @James has explained.
Either initialize variable tryAgain or add else statement for two if with the values of "tryAgain" in them.
IIM
Practically a Master Poster
653 posts since Jun 2011
Reputation Points: 127
Solved Threads: 140
Skill Endorsements: 8