Need help with creating the Ellipsoidlistapp.java lost on how to do this one plz help the two files are also listed below. The help is most appreciated thanks. http://s000.tinyupload.com/?file_id=98318520435391164412-- Link to instructions
I really need the help
Ellipsoid.java
import java.text.DecimalFormat; /** main. */ public class Ellipsoid /** *Prints encoded message *Module 4 - Project 4 *@param args Command line arguments - not used. */
{ /** main. *@param args Command line arguments - not used. */ private String label = ""; private double a = 0; private double b = 0; private double c = 0; /** main. * @param an fff * @param bn ddd * @param cn dddd * @param labelIn dfe */
public Ellipsoid(String labelIn, double an, double bn, double cn) /** * @param an fff * @param bn ddd * @param cn dddd * @param labelIn dfe */ { setLabel(labelIn); setA(an); setB(bn); setC(cn); }
/** return. * * @return label */ public String getLabel() { return label; }
/** return. * * @param labela dree * @return if String not null * return true */ public boolean setLabel(String labela) /** * @param labela dr */ { if (label != null) { this.label = label.trim(); return true; } else { return false; } } /** return. * * @return a */ public double getA() { return a; }
/** return. * * @param an fff * @return if a>0 is true */ public boolean setA(double a) /**return. * * @param an dff * */ { if (a > 0) { this.a = a; return true; } else { return false; } } /**return. * * @return b */ public double getB() { return b; }
/**return. * * @param bn gggf * @return true if b>0 */ public boolean setB(double b) /**return. * * @param bn dfff * */ { if (b > 0) { this.b = b; return true; } else { return false; } } /**return. * * @return c */
public double getC() { return c; }
/**return. * * @param cn ddd * @return true if c>0 */
public boolean setC(double c) /** return. * @param c dod */ { if (c > 0) { this.c = c; return true; } else { return false; } } /**return. * * @return volume calculated */ public double volume() { return (4 * Math.PI * a * b * c) / 3; }
/**return. * * @return calculated surfaceArea */ public double surfaceArea() { double sa = (Math.pow((a * b), 1.6) + Math.pow((a * c), 1.6) + Math.pow((b * c), 1.6)) / 3; sa = 4 * Math.PI * Math.pow(sa, (1.0 / 1.6)); return sa; }
/**return. * * @return String object */ public String toString() { DecimalFormat decimalFormat = new DecimalFormat("#,##0.0###"); return "Ellipsoid \"" + label + "\" with axes a = " + getA() + ", b = " + getB() + ", c = " + getC() + " units has: \tvolume = " + decimalFormat.format(volume()) + " cubic units" + " \tsurface area = " + decimalFormat.format(surfaceArea()) + " square units"; } }
Project: Ellipsoid List App Page 4 of 7 Ellipsoid List.java Requirements: Create an EllipsoidList class that stores the name of the list and an ArrayList of Ellipsoid objects. It also includes methods that return the name of the list, number of Ellipsoid objects in the EllipsoidList, total volume, total surface area, average volume, and average surface for all Ellipsoid objects in the EllipsoidList. The toString method returns a String containing the name of the list followed by each Ellipsoid in the ArrayList, and a summaryInfo method returns summary information about the list (see below). Design: The EllipsoidList class has two fields, a constructor, and methods as outlined below. (1) Fields (or instance variables): (1) a String representing the name of the list and (2) an ArrayList of Ellipsoid objects. These are the only fields (or instance variables) that this class should have, and both should be private. (2) Constructor: Your EllipsoidList class must contain a constructor that accepts a parameter of type String representing the name of the list and a parameter of type ArrayList
representing the list of Ellipsoid objects. These parameters should be used to assign the fields described above (i.e., the instance variables). (3) Methods: The methods for EllipsoidList are described below. o getName: Returns a String representing the name of the list. numberOfEllipsoids: Returns an int representing the number of Ellipsoid objects in the EllipsoidList. If there are zero Ellipsoid objects in the list, zero should be returned. o totalvolume: Returns a double representing the total volume for all Ellipsoid objects in the list. If there are zero Ellipsoid objects in the list, zero should be returned. o totalSurfaceArea: Returns a double representing the total surface area for all Ellipsoid objects in the list. If there are zero Ellipsoid objects in the list, zero should be returned. o averageVolume: Returns a double representing the average volume for all Ellipsoid objects in the list. If there are zero Ellipsoid objects in the list, zero should be returned. o averageSurfaceArea: Returns a double representing the average surface area for all Ellipsoid objects in the list. If there are zero Ellipsoid objects in the list, zero should be returned toString: Returns a String (does not begin with ) containing the name of the list followed by each Ellipsoid in the ArrayList. In the process of creating the return result, this toString() method should include a while loop that calls the toString() method for each Ellipsoid object in the list adding a before and after each). Be sure to include appropriate newline escape sequences. For an example, see lines 3 through 16 in the output below from EllipsoidListApp for the Ellipsoid_data_1.txt input file. [Note that the toString result should not include the summary items in lines 18 through 24 of the example. These lines represent the return value of the summaryInfo method below.) summaryInfo: Returns a String (does not begin with (n) containing the name of the o values. For an example, see lines 18 through 24 in the output below from EllipsoidListApp for the Ellipsoid_data_1.txt input file. The second example below shows the output from EllipsoidListApp for the Ellipsoid_data_0.txt input file which contains a list name but no Ellipsoid data. Code and Test: Remember to import java.util.ArrayList. Each of the last five methods above requires that you use a loop (i.e., a while loop) to retrieve each object in the ArrayList. As you implement your EllipsoidList class, you can compile it and then test it using interactions. However, it may be easier to create a class with a simple main method that creates an EllipsoidList object and calls its methods. Ellipsoid ListApp.java Requirements: Create an EllipsoidListApp class with a main method that (1) reads in the name of the data file entered by the user and (2) reads list name and Ellipsoid data from the file, (3) creates Ellipsoid objects, storing them in a local ArrayList of Ellipsoid objects, and finally, (4) creates an EllipsoidList object with the name of the list and the ArrayList of Ellipsoid objects, and then prints the EllipsoidList object followed summary information about the EllipsoidList object. All input and output for this project must be done in the main method. Design: The main method should prompt the user to enter a file name, and then it should read in the data file. The first record (or line) in the file contains the name of the list. This is followed by the data for the Ellipsoid objects. Within a while loop, each set of Ellipsoid data (i.e., label, and axes a, b, and c) is read in, and an Ellipsoid object should be created and added to the local ArrayList of Ellipsoid objects. After the file has been read in and the ArrayList has been populated, the main method should create an EllipsoidList object with the name of the list and the ArrayList of Ellipsoid objects as parameters in the constructor. It should then print the EllipsoidList object, and then print the summary information about the EllipsoidList (i.e., print the value returned by the summaryInfo method for the EllipsoidList). The output from two runs of the main method in EllipsoidListApp is shown below. The first is produced after reading in the Ellipsoid_data_1.txt file, and the second is produced after reading in the Ellipsoid_data_0.txt file. Your program output should be formatted exactly as shown on the next page. Project: Ellipsoid List App Page 6 of 7 Line # Program output 1 2 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 GRASP exec: java EllipsoidListApp Enter file name: Ellipsoid_data_1.txt Ellipsoid Test List Ellipsoid "Ex 1" with axes a = 1.0, b = 2.0, c = 3.0 units has: volume = 25.1327 cubic units surface area = 48.9366 square units Ellipsoid "Ex 2" with axes a = 2.3, b = 5.5, C = 7.4 units has: volume = 392.1127 cubic units surface area = 317.9245 square units Ellipsoid "Ex 3" with axes a = 123.4, b = 234.5, C = 345.6 units has: volume = 41,890,963.5508 cubic units surface area = 674,164.7034 square units Summary for Ellipsoid Test List Number of Ellipsoid objects: 3 Total Volume: 41,891,380.796 cubic units Total Surface Area: 674,531.564 square units Average volume: 13,963,793.599 cubic units Average Surface Area: 224,843.855 square units --GRASP: operation complete. ---- Line # 1 2 Program output --GRASP exec: java EllipsoidListApp Enter file name: Ellipsoid_data_0.txt Ellipsoid Empty Test List 7 8 9 10 11 12 Summary for Ellipsoid Empty Test List Number of Ellipsoid objects: 0 Total Volume: 0.0 cubic units Total Surface Area: 0.0 square units Average Volume: 0.0 cubic units Average Surface Area: 0.0 square units --GRASP: operation complete. Code: Remember to import java.util.ArrayList, java.util.Scanner, and java.io.File, and java.io.FileNotFoundException prior to the class declaration. Your main method declaration should indicate that main throws FileNotFoundException. After your program reads in the file name from the keyboard, it should read in the data file using a Scanner object that was created on a file using the file name entered by the user. = new Scanner (new File(fileName)); You can assume that the first line in the data file is the name of the list, and then each set of four lines contains the data from which an Ellipsoid object can be created. After the name of the list has been read and assigned to a local variable, a while loop should be used to read in the Ellipsoid Project: Ellipsoid List App Page 7 of 7 the blank is the name of the Scanner you created on the file. Each iteration through the loop reads four lines. As each of the lines is read from the file, the respective local variables for the Ellipsoid data items (label, a, b, and c) should be assigned, after which the Ellipsoid object should be created and added to a local ArrayList of Ellipsoid objects. The next iteration of the loop should then read the next set of four lines then create the next Ellipsoid object and add it to the local ArrayList of Ellipsoid objects, and so on. After the file has been processed (i.e., when the loop terminates after the hasNext method returns false), name of the list and the ArrayList of Ellipsoid objects should be used to create an EllipsoidList object. The list should be printed by printing a leading in and the EllipsoidList object. Finally, the summary information is printed by printing a leading and the value returned by the summaryInfo method invoked on the EllipsoidList object. Test: You should test your program minimally (1) by reading in the Ellipsoid_data_1.txt input file, which should produce the first output above, and (2) by reading in the Ellipsoid_data_0.txt input file, which should produce the second output above. Although your program may not use all of the methods in the EllipsoidList and Ellipsoid classes, you should ensure that all of your methods work according to the specification. You can either user interactions in jGRASP or you can write another class and main method to exercise the methods. Web-CAT will test all methods to determine your project grade. General Notes 1. All input from the keyboard and all output to the screen should done in the main method. Only one Scanner object on System.in should be created and this should be done in the main method. All printing (i.e., using the System.out.print and/or System.out.println methods) should be in the main method. Hence, none of your methods in the Ellipsoid class should do any input/output (1/0). 2. Be sure to download the test data files (Ellipsoid_data_l.txt and Ellipsoid_data_0.txt) and store them in same folder as your source files. It may be useful examine the contents of the data files. Find the data files in the jGRASP Browse tab and then open each data file in GRASP to see the items that your program will be reading from the file. Be sure to close the data files without changing them. Ellipsoid Test List Ex 1 1 2 3 Ex 2 2.3 5.5 7.4 Ex 3 123.4 234.5 345.6 Ellipsoid Empty Test List Project: Ellipsoid List App Page 4 of 7 Ellipsoid List.java Requirements: Create an EllipsoidList class that stores the name of the list and an ArrayList of Ellipsoid objects. It also includes methods that return the name of the list, number of Ellipsoid objects in the EllipsoidList, total volume, total surface area, average volume, and average surface for all Ellipsoid objects in the EllipsoidList. The toString method returns a String containing the name of the list followed by each Ellipsoid in the ArrayList, and a summaryInfo method returns summary information about the list (see below). Design: The EllipsoidList class has two fields, a constructor, and methods as outlined below. (1) Fields (or instance variables): (1) a String representing the name of the list and (2) an ArrayList of Ellipsoid objects. These are the only fields (or instance variables) that this class should have, and both should be private. (2) Constructor: Your EllipsoidList class must contain a constructor that accepts a parameter of type String representing the name of the list and a parameter of type ArrayList representing the list of Ellipsoid objects. These parameters should be used to assign the fields described above (i.e., the instance variables). (3) Methods: The methods for EllipsoidList are described below. o getName: Returns a String representing the name of the list. numberOfEllipsoids: Returns an int representing the number of Ellipsoid objects in the EllipsoidList. If there are zero Ellipsoid objects in the list, zero should be returned. o totalvolume: Returns a double representing the total volume for all Ellipsoid objects in the list. If there are zero Ellipsoid objects in the list, zero should be returned. o totalSurfaceArea: Returns a double representing the total surface area for all Ellipsoid objects in the list. If there are zero Ellipsoid objects in the list, zero should be returned. o averageVolume: Returns a double representing the average volume for all Ellipsoid objects in the list. If there are zero Ellipsoid objects in the list, zero should be returned. o averageSurfaceArea: Returns a double representing the average surface area for all Ellipsoid objects in the list. If there are zero Ellipsoid objects in the list, zero should be returned toString: Returns a String (does not begin with ) containing the name of the list followed by each Ellipsoid in the ArrayList. In the process of creating the return result, this toString() method should include a while loop that calls the toString() method for each Ellipsoid object in the list adding a before and after each). Be sure to include appropriate newline escape sequences. For an example, see lines 3 through 16 in the output below from EllipsoidListApp for the Ellipsoid_data_1.txt input file. [Note that the toString result should not include the summary items in lines 18 through 24 of the example. These lines represent the return value of the summaryInfo method below.) summaryInfo: Returns a String (does not begin with (n) containing the name of the o values. For an example, see lines 18 through 24 in the output below from EllipsoidListApp for the Ellipsoid_data_1.txt input file. The second example below shows the output from EllipsoidListApp for the Ellipsoid_data_0.txt input file which contains a list name but no Ellipsoid data. Code and Test: Remember to import java.util.ArrayList. Each of the last five methods above requires that you use a loop (i.e., a while loop) to retrieve each object in the ArrayList. As you implement your EllipsoidList class, you can compile it and then test it using interactions. However, it may be easier to create a class with a simple main method that creates an EllipsoidList object and calls its methods. Ellipsoid ListApp.java Requirements: Create an EllipsoidListApp class with a main method that (1) reads in the name of the data file entered by the user and (2) reads list name and Ellipsoid data from the file, (3) creates Ellipsoid objects, storing them in a local ArrayList of Ellipsoid objects, and finally, (4) creates an EllipsoidList object with the name of the list and the ArrayList of Ellipsoid objects, and then prints the EllipsoidList object followed summary information about the EllipsoidList object. All input and output for this project must be done in the main method. Design: The main method should prompt the user to enter a file name, and then it should read in the data file. The first record (or line) in the file contains the name of the list. This is followed by the data for the Ellipsoid objects. Within a while loop, each set of Ellipsoid data (i.e., label, and axes a, b, and c) is read in, and an Ellipsoid object should be created and added to the local ArrayList of Ellipsoid objects. After the file has been read in and the ArrayList has been populated, the main method should create an EllipsoidList object with the name of the list and the ArrayList of Ellipsoid objects as parameters in the constructor. It should then print the EllipsoidList object, and then print the summary information about the EllipsoidList (i.e., print the value returned by the summaryInfo method for the EllipsoidList). The output from two runs of the main method in EllipsoidListApp is shown below. The first is produced after reading in the Ellipsoid_data_1.txt file, and the second is produced after reading in the Ellipsoid_data_0.txt file. Your program output should be formatted exactly as shown on the next page. Project: Ellipsoid List App Page 6 of 7 Line # Program output 1 2 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 GRASP exec: java EllipsoidListApp Enter file name: Ellipsoid_data_1.txt Ellipsoid Test List Ellipsoid "Ex 1" with axes a = 1.0, b = 2.0, c = 3.0 units has: volume = 25.1327 cubic units surface area = 48.9366 square units Ellipsoid "Ex 2" with axes a = 2.3, b = 5.5, C = 7.4 units has: volume = 392.1127 cubic units surface area = 317.9245 square units Ellipsoid "Ex 3" with axes a = 123.4, b = 234.5, C = 345.6 units has: volume = 41,890,963.5508 cubic units surface area = 674,164.7034 square units Summary for Ellipsoid Test List Number of Ellipsoid objects: 3 Total Volume: 41,891,380.796 cubic units Total Surface Area: 674,531.564 square units Average volume: 13,963,793.599 cubic units Average Surface Area: 224,843.855 square units --GRASP: operation complete. ---- Line # 1 2 Program output --GRASP exec: java EllipsoidListApp Enter file name: Ellipsoid_data_0.txt Ellipsoid Empty Test List 7 8 9 10 11 12 Summary for Ellipsoid Empty Test List Number of Ellipsoid objects: 0 Total Volume: 0.0 cubic units Total Surface Area: 0.0 square units Average Volume: 0.0 cubic units Average Surface Area: 0.0 square units --GRASP: operation complete. Code: Remember to import java.util.ArrayList, java.util.Scanner, and java.io.File, and java.io.FileNotFoundException prior to the class declaration. Your main method declaration should indicate that main throws FileNotFoundException. After your program reads in the file name from the keyboard, it should read in the data file using a Scanner object that was created on a file using the file name entered by the user. = new Scanner (new File(fileName)); You can assume that the first line in the data file is the name of the list, and then each set of four lines contains the data from which an Ellipsoid object can be created. After the name of the list has been read and assigned to a local variable, a while loop should be used to read in the Ellipsoid Project: Ellipsoid List App Page 7 of 7 the blank is the name of the Scanner you created on the file. Each iteration through the loop reads four lines. As each of the lines is read from the file, the respective local variables for the Ellipsoid data items (label, a, b, and c) should be assigned, after which the Ellipsoid object should be created and added to a local ArrayList of Ellipsoid objects. The next iteration of the loop should then read the next set of four lines then create the next Ellipsoid object and add it to the local ArrayList of Ellipsoid objects, and so on. After the file has been processed (i.e., when the loop terminates after the hasNext method returns false), name of the list and the ArrayList of Ellipsoid objects should be used to create an EllipsoidList object. The list should be printed by printing a leading in and the EllipsoidList object. Finally, the summary information is printed by printing a leading and the value returned by the summaryInfo method invoked on the EllipsoidList object. Test: You should test your program minimally (1) by reading in the Ellipsoid_data_1.txt input file, which should produce the first output above, and (2) by reading in the Ellipsoid_data_0.txt input file, which should produce the second output above. Although your program may not use all of the methods in the EllipsoidList and Ellipsoid classes, you should ensure that all of your methods work according to the specification. You can either user interactions in jGRASP or you can write another class and main method to exercise the methods. Web-CAT will test all methods to determine your project grade. General Notes 1. All input from the keyboard and all output to the screen should done in the main method. Only one Scanner object on System.in should be created and this should be done in the main method. All printing (i.e., using the System.out.print and/or System.out.println methods) should be in the main method. Hence, none of your methods in the Ellipsoid class should do any input/output (1/0). 2. Be sure to download the test data files (Ellipsoid_data_l.txt and Ellipsoid_data_0.txt) and store them in same folder as your source files. It may be useful examine the contents of the data files. Find the data files in the jGRASP Browse tab and then open each data file in GRASP to see the items that your program will be reading from the file. Be sure to close the data files without changing them. Ellipsoid Test List Ex 1 1 2 3 Ex 2 2.3 5.5 7.4 Ex 3 123.4 234.5 345.6 Ellipsoid Empty Test List