Branching Topic 4.3.8 / Core
Key points
  • how to change the direction of a program depending on conditions;
  • the if statement;
  • the switch statement.
Vocabulary
  • boolean;
  • selection;
  • nesting.
Resources
  • Kjell chapter 12 - 14
Related topics

Starter

If - one of the biggest words in the English language

Tasks
  1. Work through the presentation on Branching.
  2. Pick up where you left off with the HelloThere project, but this time turn it into a totally interactive conversation where the computer's behaviour varies according to the answers given.
  3. Here is a version of the AddingMachine project. Adapt it to allow the user to choose addition, subtraction, multiplication or division.
  4. Study and run this source code for a temperature converter. Rewrite it using the switch statement.
  5. Write a currency converter that can convert between euros, dollars, pounds AND another currency of your choice. Your program must be user-friendly and allow all of the 12 possible conversions.
  6. Extension work: Try the Warmup-1 Java exercises on the CodingBat web site.
  7. Continue to work through the problems in the Java Problem Set 1<.
  8. Try some of the programming exercises at the end of Eck's chapter 2.
-->