From edecade429a11a79fbb3c459bfb3688cee76f66b Mon Sep 17 00:00:00 2001 From: "Dr. Martin Goik" <goik@hdm-stuttgart.de> Date: Thu, 18 Apr 2019 17:00:05 +0200 Subject: [PATCH] Loop reption limit by user input --- Doc/Sd1/statements.xml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Doc/Sd1/statements.xml b/Doc/Sd1/statements.xml index 4cb937489..756a44de0 100644 --- a/Doc/Sd1/statements.xml +++ b/Doc/Sd1/statements.xml @@ -2125,16 +2125,22 @@ Do not copy!</screen></td> <figure xml:id="sd1_fig_loopParamSolutionSyntaxSugar"> <title>Combining increment and termination condition</title> - <programlisting language="java">final int repetitions = scan.nextInt(); + <informaltable border="0"> + <tr> + <td valign="top"><programlisting language="java">System.out.print("Enter repetitions: "); +final int repetitions = scan.nextInt(); int loopCounter = 1; while (loopCounter++ <= repetitions) { System.out.println("Do not copy!"); -}</programlisting> +}</programlisting></td> - <screen>Do not copy! + <td valign="top"><screen>Enter repetitions: 3 +Do not copy! Do not copy! -Do not copy!</screen> +Do not copy!</screen></td> + </tr> + </informaltable> </figure> <figure xml:id="sd1_fig_whileSyntax"> @@ -2315,12 +2321,12 @@ while (i < 5 <co linkends="sd1_callout_whileLoopJustCounting-2" ... }</programlisting></td> - <td><programlisting language="java">{ - int i = 0; <coref linkend="sd1_callout_whileLoopJustCounting-1-co"/> // Block local variable - while (i < 5 <coref linkend="sd1_callout_whileLoopJustCounting-2-co"/>) { - ... - i++; <coref linkend="sd1_callout_whileLoopJustCounting-3-co"/> - } + <td><programlisting language="java">int i = 0; <coref + linkend="sd1_callout_whileLoopJustCounting-1-co"/> + +while (i < 5 <coref linkend="sd1_callout_whileLoopJustCounting-2-co"/>) { + ... + i++; <coref linkend="sd1_callout_whileLoopJustCounting-3-co"/> }</programlisting></td> </tr> </informaltable> -- GitLab