Skip to content
Snippets Groups Projects
Commit edecade4 authored by Goik Martin's avatar Goik Martin
Browse files

Loop reption limit by user input

parent 432ea1e2
No related branches found
No related tags found
No related merge requests found
......@@ -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++ &lt;= 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 &lt; 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 &lt; 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 &lt; 5 <coref linkend="sd1_callout_whileLoopJustCounting-2-co"/>) {
...
i++; <coref linkend="sd1_callout_whileLoopJustCounting-3-co"/>
}</programlisting></td>
</tr>
</informaltable>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment