Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

x-3+1, x23 Let f(x) = -*+3, * Answered: 1 week ago

Answered: 1 week ago

Question

Do you currently have a team agreement?

Answered: 1 week ago

Question

How will the members be held accountable?

Answered: 1 week ago