Java loop is not terminating -
can tell me why loop continuous?
while(sum !=7 || sum!=pt){ system.out.println(sum); die1.roll(); die2.roll(); sum = (die1.getnumber() + die2.getnumber()); joptionpane.showmessagedialog(null, "the sum of numbers "+sum); }
even if sum equal 7 or variable pt loop keep on going reason.
change ||
&&
. loop continue while 1 of conditions evaluates true. in order make stop when 1 becomes true, need change boolean operator.
Comments
Post a Comment