0
How to stop this loop?
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner a = new Scanner(System.in); int x=a.nextInt(); int y=a.nextInt(); int n=x+y; while (n < 42) { System.out.println("ok"); y=y+10; } } } //never ending loop, how to make it stop at some point?
3 Antworten
+ 4
add something to n inside the loop
+ 3
you should be checking value for n not y so change it to n=n+10;
+ 2
It worked, tysm!