java - Why deos my "While" loop keep going on? -
my loop never stops, can't seem understand wrong. i'm doing project class , i'm new loops kind of confused. please tell me how resolve issue.
import java.util.scanner; public class fraccalc { public static void main(string[] args) { scanner scan = new scanner(system.in); { boolean quit = true; system.out.println("welcome fraccalc"); system.out.println("type expressions fractions, , evaluate them"); string reply = scan.nextline(); while (quit = true) { if (answer.equals("quit")){ system.out.println("thanks forr running fraccalc!"); break; } else { system.out.println("i can process 'quit' now"); } } } } }
put string reply = scan.nextline();
within loop.
try following:
import java.util.scanner; public class fraccalc { public static void main(string[] args) { scanner scan = new scanner(system.in); system.out.println("welcome fraccalc"); system.out.println("type expressions fractions, , evaluate them"); string reply = scan.nextline(); { if (answer.equals("quit")) { system.out.println("thanks forr running fraccalc!"); break; } else { system.out.println("i can process 'quit' now"); } reply = scan.nextline(); } while (true); } }
java loops if-statement while-loop
No comments:
Post a Comment