Skip to content

Commit ff0772d

Browse files
committed
added an exercise code block
1 parent 4727ea1 commit ff0772d

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

source/ch2_firstjavaprogram.ptx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,39 @@ Hello World!
366366
</program>
367367
</listing>
368368

369+
370+
371+
<exercise xml:id="java-name-color-practice-exercise" label="java-name-color-practice">
372+
<statement>
373+
<p>
374+
Now that we have seen the hello world program in both Python and Java, use the ideas present in this chapter to write a Java program that prints your name and your favorite color.
375+
</p>
376+
<program xml:id="java-name-color-practice" interactive="activecode" language="java">
377+
<input>
378+
public class NameColor {
379+
public static void main(String[] args) {
380+
// Write your code here
381+
382+
}
383+
}
384+
</input>
385+
</program>
386+
</statement>
387+
<solution>
388+
<program language="java">
389+
<input>
390+
public class NameColor {
391+
public static void main(String[] args) {
392+
System.out.println("Name: Alex");
393+
System.out.println("Favorite Color: Blue");
394+
}
395+
}
396+
</input>
397+
</program>
398+
</solution>
399+
</exercise>
400+
401+
369402
</section>
370403

371404

0 commit comments

Comments
 (0)