CIS 67 Lab 1
1. Type in the classes on p. 25 and 26 and save them as separate .java
files. Figure NameInStars may have a syntax error -- if so, correct it.
2. Build the project and run it.
3. Create a project Coins.
4. Download
and store the file CoinChanger.java
5. Download
and store the file ChangeCoinsApp.java in the project.
6. Compile and run the program.
7. Make the two changes below (through 8) and then compile and run the
program again.
Add another data field for half-dollars. Process this data field
in class CoinChanger like the others. Your modified application should
read in half-dollars.
8. Add a boolean method isSuperSaver() to class CoinChanger that returns
true if the coin collection is worth more than $5. Apply this method in
class ChangeCoinsApp and append the string "Congratulations, you are a
super saver" to the end of String message if the user is a super saver.
Hint: the method
public boolean isPostive() {
return sqrt(x) > 1.0;
}
returns true if the square root of x is greater than one. Your new method
should look similar to this one.
9. Assignments for next time: Projects #4 and 5, p. 103. Follow the
software development method and place the documentation in a long comment
before each program. Hint: You can do these projects using a single application
class with a main method (as you would in C) but it would be better to
write a class Rectangle and a class Yard for #6 (see Section 3.5 for an
example) and a class Fraction for #6 with methods that perform the required
computations.