Assignment 5 – Planet Processor

Maximum Points = 50

 

 The purpose of this lab is to introduce you to the creation of objects of a user-defined class and to the Scanner, File, and Applet classes in the Java programming language. In this lab you will write a program that reads data from a file and then generates an applet that displays a listing of the planets and their data from the file.

* Your program must read the data from a file called planets.txt [HINT: You will need to use the Scanner class described on page 1018 (example from keyboard on page 157)] and example with a File class described on page 997 (examples in CougarView’s Instructor Links and Files in the Scanner and URL Dissector folders in the Solutions folder.) NOTE: you will need to use a delimiter as illustrated in the examples to separate the data components.

*   The data in the file will consist of five (5) planets (each planet will consist of a name, radius, mass, and distance [from the sun]) where each component will be separated by the percent sign (%) symbol as shown below:

 

PlanetX%40%200%1000

Mercury%2440%3.3e+23%57909100

...:

 

*   Your program must include a class that will hold the Planet data (complete with constructor(s), get and set methods for each instance variable, and a toString method that returns the contents of the instance variables). Include additional methods getVolume (v=4/3 π r3), getSurfaceArea (sa=4 πr2), and getDensity (den = mass/volume).

Once your program has collected the data, you need to display the listing of the five planets from the file using the Applet class described on page 991 (examples on page 63, in CougarView’s Instructor Links and Files in the Applet folder in the Solutions folder, and http://csc.columbusstate.edu/summers/NOTES/JAVA.HTM) [NOTE: that Applets use a method init instead of the main method]

Your listing should have a title at the top in a larger font (and possible different font face and color) along with a graphic. The listing of the five planets should display the data from the file, PLUS the computed data for each planet.

List somewhere on the bottom of the “page” the total mass, volume, and surface area as well as the average density of the five planets.

Modularize your program to minimize the amount of changes you would need to make if we change the number of planets.

 

EXTRA CHALLENGE: add images.

 

Make sure that your program uses proper indentation and complete documentation. See http://csc.columbusstate.edu/summers/NOTES/1301/style.htm for guidelines.

The program heading should occur at the top of the program and should include:

               /**
                * PROGRAM SPECIFICATIONS
                * NARRATIVE DESCRIPTION:
                *
                * @author (your name) 
                * @version (date)
                */

 

  (Due before class on Wednesday, March 21, 2012) Submit your .java files containing your program and your timesheet documenting your time to the dropbox in WebCT..

 Grades are determined using the following scale:

Grading Rubric  (Word document)