# from your cs21/hw04 subdirectory: % cp ~newhall/public/cs21/hw04/* . % lsYou can use the makefile to compile your programs (you don't have to use it, but it is easier to use a makefile). To compile just enter the make command, make will read the compilation rules in the Makefile to compile your .java files to .class files. To remove all .class files, type 'make clean' (this is a good way to force recompilation on next make):
% make % ls Account.class ManageAccounts.class Sphere.java Account.java ManageAccounts.java SphereDriver.class Makefile Sphere.class SphereDriver.java % make clean % ls Account.java Makefile ManageAccounts.java Sphere.java SphereDriver.java
Please complete the following 2 programs and turn them in using cs21handin. You should work on this assignment by yourself (no partners).
Next, open up ManageAccounts.java and modify it so that it
See the comments in the code for more information about these.
Once this works, add a method named compareTo to your Sphere class. The compareTo method should take a Sphere object as a parameter, and return one of the following values:
This program creates three Sphere objects Enter the diameter of the first Sphere: 8.9 Enter the diameter of the second Sphere: 5 Enter the diameter of the third Sphere: 2.3 ------------------------------------ Sphere with diameter 8.9, volume 369.12, surface area 248.85 Sphere with diameter 5.0, volume 65.45, surface area 78.54 Sphere with diameter 2.3, volume 6.37, surface area 16.62 ------------------------------------ Spheres from smallest to largest: --------------------------------- Sphere with diameter 2.3, volume 6.37, surface area 16.62 Sphere with diameter 5.0, volume 65.45, surface area 78.54 Sphere with diameter 8.9, volume 369.12, surface area 248.85
Remember to comment all methods in your class with the following:
/** * ComputeAveGrade: this method calculates the student's * average grade, allowing up to two new * grade values to be included in the ave * * @param grade1: a new grade value between 0 and 100, pass in -1 if * you want to compute gpa without including a new grade * @param grade2: a new grade value between 0 and 100, pass in -1 if * want to compute gpa without including a 2nd new grade * * @return the student's average grade as a value between 0.0 and 100.0 */