Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

code in java Specifications Overview: You will write a program this week that is composed of two classes: (1) one named Ellipsoid that defines Ellipsoid

code in java image text in transcribed
image text in transcribed
image text in transcribed
Specifications Overview: You will write a program this week that is composed of two classes: (1) one named Ellipsoid that defines Ellipsoid objects, and (2) the other, EllipsoidApp, which has a main method that reads in data, creates an Ellipsoid object, and then prints the object. An Ellipsoid is a 3-D object whose plane sections are ellipses defined by three axes (a,b,c) as depicted below. The formulas are provided to assist you in computing return values for the respective methods in the Ellipsoid class described in this project. Formulas for volume (V) and surface area (S) are shown below. V=34abcS4(3(ab)1.6+(ac)1.6+(bc)1.6)1/.6 - Ellipsoid.java Requirements: Create an Ellipsoid class that stores the label and three axes a,b, and c. The values of the axes must be greater than zero. The Ellipsoid class also includes methods to set and get each of these fields, as well as methods to calculate the volume and surface area of the Ellipsoid object, and a method to provide a String value of an Ellipsoid object (i.e., a class instance). Design: The Ellipsoid class has fields, a constructor, and methods as outlined below. (1) Fields (instance variables): label of type String, and axes a, b, and c of type double. Initialize the String variable to "= and the double variables to 0 in their respective deelarations. These instance variables should be private so that they are not directly accessible from outside of the Ellipsoid class, and these should be the only instance variables (i.e. fields) in the class. (2) Constructor: Your Ellipsoid class must contain a public constructor that accepts four parameters (see types of above) representing the label, a,b, and c. Instead of assigning the parameters directly to the fields, the respective set method for each field (described below) should be called. For example, instead of the statement 1 abel = 1 abelin; use the statement setLabel ( abelIn); Below are examples of how the constructor could be used to create Ellipsoid objects. Note that although String and numeric literals are used for the actual parameters (or arguments) in these examples, variables of the required type could have been used instead of the literals. Ellipsoidex1=newEllipsoid(nEx1n,1,2,3);E11ipsoidex2=newEllipsoid("Ex2%,2.3,5.5,7.4);El1ipsoidex3=newEl1ipsoid("Ex3n,123.4,234.5,345.6); (3) Methods: Usually a class provides methods to access and modify each of its instance variables (known as get and set methods) along with any other required methods. The methods for Ellipsoid, which should each be public, are described below. See formulas in Code and Test below. - getLabe 1: Accepts no parameters and returns a String representing the label field. - setLabe 1: Takes a String parameter and returns a boolean. If the string parameter is not null, then the label field is set to the "trimmed" String and the method returns true. Otherwise, the method returns false and the label field is not set. getA: Accepts no parameters and retums a double representing field a. setA: Accepts a double parameter and returns a boolean as follows. If the double is greater than zero, sets field a to the double passed in and returns true. Otherwise, the method returns false and does not set the field. getB: Accepts no parameters and retums a double representing field b. set.B: Accepts a double parameter and returns a boolean as follows. If the double is greater than zero, sets field b to the double passed in and returns true. Otherwise, the method retums false and does not set the field. getC: Accepts no parameters and returns a double representing field c. - setC: Accepts a double parameter and returns a boolean as follows. If the double is greater than zero, sets field c to the double passed in and retums true. Otherwise, the method returns false and does not set the field. - volume: Accepts no parameters and returns the double value for the volume calculated using formula above and the values of axes fields a,b,c. Page 2 of 5 ect: Ellipsoid App Page 3 of 5 - surfaceArea: Accepts no parameters and returns the double value for the surface area calculated using formula above and the values of axes fields a,b,c. - toString: Returns a String containing the information about the Ellipsoid object formatted as shown below, including decimal formatting (",0,01") for the double values. Newline and tab escape sequences should be used to achieve the proper layout. In addition to the field values (or corresponding "get" methods), the following methods should be used to compute appropriate values in the tostring method: volune () and surfaceArea (). Each line should have no trailing spaces (e.g., there should be no spaces before a newline (n) character). The tostring value for ex1, ex2, and ex 3 respectively are shown below (the blank lines are not part of the tostring values). 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 E11ipsold "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 unita

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions