Objectives |
Introduce students to using loop structures in programs for error correction and execution control. |
Background |
We have already worked with if statements to detect erroneous data. But in some cases users will repeatedly enter the wrong value. In addition, some problems lend themselves to repeatedly executing the program. For example, in PA2, it would be useful to execute the program for not just one star or planet, but for a series of stars or planets of the user's choosing. This lab will explore these uses of the Java loop. |
New Terms |
|
Materials |
You will use your EightBall.java program from a prior
lab for today's lab. If you did not finish this lab, download a
model solution from EightBall.java. You will need to use some of the String methods for this lab. This is a link to the Java documentation for the methods for String. Java documentation is known as the Java APIs. A link to all of the APIs is found on our resources page. You will find on this page a list of all the methods for the String class. And by clicking a method in the method summary chart, you will go to the more detailed description of that method. |
Submission |
|
Acknowledgment |
Adapted
from an original lab by Arch Harris & Nancy Harris |
CodingBat is a web site that has practice programming problems. These are set up as individual methods. See the About page for more information.
Once item 3 is working correctly, add in a final refinement.
last update -
10/15/2012 - NLH