Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ellipsoid ListApp.java Requirements: Create an Ellipsoid ListApp class with a main method that (1) reads in the name of the data file entered by the

image text in transcribed
image text in transcribed
image text in transcribed
Ellipsoid ListApp.java Requirements: Create an Ellipsoid ListApp 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 Ellipsoid List object with the name of the list and the ArrayList of Ellipsoid objects, and then prints the Ellipsoid List object followed summary information about the Ellipsoid List 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 Ellipsoid List 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 Ellipsoid List (i.e., print the value returned by the summary Info method for the EllipsoidList). The output from two runs of the main method in Ellipsoid ListApp is shown below. The first is produced after reading in the Ellipsoid_data_Itxt file, and the second is produced after reading in the Ellipsoid_data_0.1x7 file. Your program output should be formatted exactly as shown on the next page. Page 5 of 7 Project: Ellipsoid List App Page 6 of 7 Thyaga RASP exect Java Ellipsoidist Ester file name: Ellipsoid data 1.txt Ellipsoid Test List Ellipsoid "Ex 1" with axes a -1.0, - 2.0, c-3.0 units has: volume-25.1327 cubie units surface area 48.9366 square units -7.4 units has Ellipsoid "Ex 2" with axes a - 2.3, -5.5, volume - 392.1127 cubie 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 cubie 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. Li Program output GRASP OXO Sava EllipsoidListApp Enter file name Ellipsoid data 0.txt Ellipsoid Empty Test List - Summary for Ellipsoid Enpty Test List ----- Number of Ellipsold Objects: Total Volume 0. cubie units Total Surface Area 0.0 square units Average Volume 0.0 cubie units Average Surface Areat 0.0 square units GRASPI operation complete. Code: Remember to import javautil.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 cach 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 data. The boolean expression for the while loop should be has ext() where Page 6 of 7 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 cach of the lines is read from the file, the respective local variables for the Ellipsoid data items (label, 2 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 (.e., when the loop terminates after the hasNext method return 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 Ellipsoid List object. Finally, the summary information is printed by printing a leading in and the value returned by the summary Info method invoked on the Ellipsoid List object Test: You should test your program minimally (1) by reading in the Ellipsoid data Text input file, which should produce the first output above, and (2) by reading in the Ellipsoid data 0. input file, which should produce the second output above. Although your program may not use all of the methods in the Ellipsoid List and Ellipsoid classes, you should ensure that all of your methods work according to the specification. You can either user interactions in GRASP 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 (ie, 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 1.txt and Ellipsoid data 0.x) 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 jGRASP to see the items that your program will be reading from the file. Be sure to close the data files without changing them. Page 7 of 7 Ellipsoid ListApp.java Requirements: Create an Ellipsoid ListApp 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 Ellipsoid List object with the name of the list and the ArrayList of Ellipsoid objects, and then prints the Ellipsoid List object followed summary information about the Ellipsoid List 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 Ellipsoid List 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 Ellipsoid List (i.e., print the value returned by the summary Info method for the EllipsoidList). The output from two runs of the main method in Ellipsoid ListApp is shown below. The first is produced after reading in the Ellipsoid_data_Itxt file, and the second is produced after reading in the Ellipsoid_data_0.1x7 file. Your program output should be formatted exactly as shown on the next page. Page 5 of 7 Project: Ellipsoid List App Page 6 of 7 Thyaga RASP exect Java Ellipsoidist Ester file name: Ellipsoid data 1.txt Ellipsoid Test List Ellipsoid "Ex 1" with axes a -1.0, - 2.0, c-3.0 units has: volume-25.1327 cubie units surface area 48.9366 square units -7.4 units has Ellipsoid "Ex 2" with axes a - 2.3, -5.5, volume - 392.1127 cubie 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 cubie 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. Li Program output GRASP OXO Sava EllipsoidListApp Enter file name Ellipsoid data 0.txt Ellipsoid Empty Test List - Summary for Ellipsoid Enpty Test List ----- Number of Ellipsold Objects: Total Volume 0. cubie units Total Surface Area 0.0 square units Average Volume 0.0 cubie units Average Surface Areat 0.0 square units GRASPI operation complete. Code: Remember to import javautil.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 cach 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 data. The boolean expression for the while loop should be has ext() where Page 6 of 7 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 cach of the lines is read from the file, the respective local variables for the Ellipsoid data items (label, 2 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 (.e., when the loop terminates after the hasNext method return 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 Ellipsoid List object. Finally, the summary information is printed by printing a leading in and the value returned by the summary Info method invoked on the Ellipsoid List object Test: You should test your program minimally (1) by reading in the Ellipsoid data Text input file, which should produce the first output above, and (2) by reading in the Ellipsoid data 0. input file, which should produce the second output above. Although your program may not use all of the methods in the Ellipsoid List and Ellipsoid classes, you should ensure that all of your methods work according to the specification. You can either user interactions in GRASP 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 (ie, 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 1.txt and Ellipsoid data 0.x) 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 jGRASP to see the items that your program will be reading from the file. Be sure to close the data files without changing them. Page 7 of 7

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions