Skip to content

Commit 0c2f70c

Browse files
committed
added listing tags
1 parent 331d385 commit 0c2f70c

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

source/ch4_conditionals.ptx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ if score >= 90:
8383
Here is a simple example in both Python and Java.
8484
</p>
8585

86-
87-
<program xml:id="python-if-nesting" interactive="activecode" language="python">
86+
<listing xml:id="python-if-nesting">
87+
<program interactive="activecode" language="python">
8888
<code>
8989
grade = int(input('enter a grade'))
9090
if grade &lt; 60:
@@ -99,13 +99,14 @@ else:
9999
print('A')
100100
</code> <tests> </tests>
101101
</program>
102+
</listing>
102103

103104
<p>
104105
In Java, we have a couple of ways to write this.
105106
</p>
106107

107-
108-
<program xml:id="java-ifnesting" interactive="activecode" language="java">
108+
<listing xml:id="java-ifnesting">
109+
<program interactive="activecode" language="java">
109110
<code>
110111
public class ElseIf {
111112
public static void main(String args[]) {
@@ -131,14 +132,15 @@ public class ElseIf {
131132
}
132133
</code> <tests> </tests>
133134
</program>
135+
</listing>
134136

135137
<p>
136138
We can get even closer to the <c>elif</c> statement by taking advantage of the Java rule that a single statement does not need to be enclosed in curly braces. Since the <c>if</c> is the only statement used in each <c>else</c> block, we can get away with the following.
137139
</p>
138140

139141

140-
141-
<program xml:id="java-if-else-no-nesting" interactive="activecode" language="java">
142+
<listing xml:id="java-if-else-no-nesting" >
143+
<program interactive="activecode" language="java">
142144
<code>
143145
public class ElseIf {
144146
public static void main(String args[]) {
@@ -156,6 +158,7 @@ public class ElseIf {
156158
}
157159
</code> <tests> </tests>
158160
</program>
161+
</listing>
159162
</section>
160163

161164
<section xml:id="switch">

0 commit comments

Comments
 (0)