Question
import java.util.Scanner; public class BreakAndContinue { public static void main(String [] args){ Scanner scnr = new Scanner(System.in); int result; int stop; int a; int b;
import java.util.Scanner;
public class BreakAndContinue { public static void main(String [] args){ Scanner scnr = new Scanner(System.in); int result; int stop; int a; int b; stop = scnr.nextInt(); result = 0; for (a = 0; a < 3; ++a) { System.out.print(a + ": "); for (b = 0; b < 2; ++b) { result += a + b; if (result > stop) { System.out.print("_ "); continue; } System.out.print(result + ","); } System.out.println(); } } }
INPUT: 5
OUTPUT:
0: 0,1, 1: 2,4, 2: _ _
Can someone please explain the math, especially towards the end, of this output?
Why is it not the following:
0: 0,1, 1: 2,4, 2: 4, _
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started