Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Tasks: Program Java Development Create a project called HW02 that will be used to run the groups project. In this folder should be a package

Tasks: Program Java Development

Create a project called HW02 that will be used to run the groups project. In this folder should

be a package called space.

Create four (4) class templates consisting of constants that can be publicly accessed by through their name for the table data above. You should name your classes:

a. EarthDays: Which lists the constants for the earth days shown. b. Mass: Which lists the constants for the masses shown. c. Radius: Which lists the constants for the radii shown. d. SunDistance: Which lists the constants for the planet distances from the sun.

Your constants in each the class templates above should be assigned by their planet names MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, and NEPTUNE.

Note that when you are creating class templates for this project, they should have a header block at the top of the template with the program/class name, the date created, the author(s), the title description and the date of last update. There should also be comments written throughout each class template, to provide clarity to the written code.

Create a class template called Person that has:

private data members that stores the name, age, and weight of a person.

o Thedatamembersshouldbecalledage,nameandweight.

o Theageandweightshouldbeoftypedouble.

a public constructor that updates the data members.

public methods the retrieves the individual data members.

Create a class template called Planet that has: a. private data members that stores the distance from the sun, the number of earth

days to orbit the sun, the planets name, mass and radius.

o The data members should be called distanceFromSun,

planetEarthDays, name, mass, and radius. o The data type of distanceFromSun, planetEarthDays, mass, and

radius is of type double. o ThedatatypeofnameisoftypeString.

private constant that stores the values of the gravitational constant G, the speed of light, the value of , the conversion constant from meters to miles, the conversion value of seconds to minutes, the conversion value from hours to days.

o ThedatamembersshouldbecalledG,LIGHT_SPEED,PI,TO_MILES, TO_MINUTES and TO_DAYS.

a public constructor that updates the five (5) data members.

public methods that retrieves the distance from the sun (miles), the number of earth

days, the planets name, mass (kg) and radius (miles).

o The methods for the distances should convert the values from meters to

miles and return the value in miles. o Methodnames:getDistanceFromSun,getNoOfEarthDays,getName,

getMass and getRadius. o Thedatamembersshouldnotbeupdatedandremaininunitsofmeters.

e. public methods that retrieves the planets free fall acceleration (m/s.s), time for sunlight to reach the destination planet (mins) and approximation of orbital speed (miles/hr).

o Themethodsshouldcreatelocalvariablesthatareusedtoreturnthevalues when requested.

o Method names: getFreeFall, getTimeForSunlight, and getSpeedOfOrbit.

o It should be noted that most planetary trajectories around the sun are elliptical, but if we use a crude approximation of a circular path, we can find a crude approximation of the orbital speed. Note: a circle is a type of ellipse.

f. a public method that returns a string of characters, that allows the printing of the planet data information.

o ThemethodnameshouldbenamedgetPlanetDataandshouldreturnas a formatted string the planets name, free fall acceleration in (m/s.s), mass (kg), radius (miles), distance from sun (miles), number of earth days to orbit sun (earth days), and time for sunlight (minutes).

o Thestringshouldhavetheunitsattachedforeachmeasurementdisplayed. o Eachmeasurementshouldbequotedto2decimalplaces.

VII. Create

private data members that stores the identity, role and destination planet, of an

astronaut. o Thedatamembersshouldbecalledidentity,roleandplanet. o ThedatatypeofidentityisoftypePerson. o ThedatatypeofplanetisoftypePlanet. o ThedatatypeofroleisoftypeString.

private constant that stores the values of the number of earth days, the earths gravitational acceleration and the conversion from lbs to Newtons (N).

o The data members should be called EARTH_DAYS, EARTH_GRAVITY and TO_NEWTONS.

public constructors that updates the data members. o Yourteamshouldmakeatleastthreeconstructors,with:

one accepting the identity, role, and destination planet of an astronaut.

one accepting the identity, and role of an astronaut.

one accepting the identity of an astronaut.

a class template called Astronaut that has:

o Your team should discuss an efficient and logical way to best implement these constructors and discuss this in a report.

d. public methods the retrieves the mass (kg), and age (years) and weight (lbs) of astronaut on destination planet.

o These separate methods create local variables that are used to return the values of the mass (kg) and converted age (years) and weight (lbs).

o Method names: getMass, getPlanetaryAge, and getPlanetaryWeight.

o The getMass method should be overloaded so that one version has no parameters and the other has a free fall acceleration parameter.

o The data members should not be updated and remain in their original units of kg, years and lbs.

e. Two public methods return a string of characters, that allows the printing of the astronaut information.

o ThesemethodshavethesamemethodnamegetAstronautData,butone accepts the role of the astronaut and the other receives no arguments.

o The methods should return as a formatted string, the astronauts name, title(role), earth age, earth weight, mass, name of destination planet, age on planet, and weight on planet.

VIII. Create a class template called SpaceCraft that has:

private data members that stores the identity of three astronauts in their role as

commander, pilot, and mission specialist, as well as the attributes of the destination planet.

o Thedatamembersshouldbecalledcommander,pilot,specialistand planet.

public constructors that updates the data members.

public methods the retrieves and prints the data for the commander, pilot, mission

specialist and planet to the console output window in separate methods for each of the astronauts and planet.

o Method names: showCommanderData, showPilotData, showSpecialistData, and showPlanetData.

a public method named showDiagnostics that prints out the commander data, pilot data, mission specialist data and the planetary data to the console output window. o Yourteamshoulddiscussanefficientandlogicalwaytobestimplementthis

method and discuss this in a report.

IX. Create

instantiate (create an instance /object of the class defined type) objects of the

EarthDays, Mass, Radius, SunDistance, Person, Planet, Astronaut and SpaceCraft classes. Use names that express a logical connection between their use and construction.

test the showDiagnostics method of the SpaceCraft object. Note: this is the ONLY test that should be run.

a program called Test to:

Calculations, Constants and Conversions: Constants:

Gravitational Constant G: 6. 67 x 10-11

Speed of Light: 2.99792458 x 108 m/s

: 3.14159265359

Earth Days: 365.25

Free Fall Acceleration (Earth): 9.81m/s.s

Conversions:

Convert from lbs to N

N = lbs / 4.448

Convert from meters to miles

m = mi / 1609.344

Convert from seconds to minutes

s = mins / 60.0

Convert from hours to days

hrs = days / 24.0

Calculations:

Free Fall Acceleration

freeFall = (G * mass) / (radius * radius)

Mass

m = Weight(Newton) / freeFall

Planet Weight

w = ( mass) (freeFall)

Planet Age

y =(x * 365)/d

where x is the age on Earth, y is the age on the planet Y, and d is the number of Earth days the planet Y takes to travel around the Sun.

Approximation of Orbital Speed of planet with given radius r, the number of earth days it takes to orbit the sun T

Speed =(2 pi r)/T

Formatting

Although we desire such a high level of precision by double values during computations, we may not when displaying the result. We can restrict the number of decimal places to display by using the DecimalFormat class from the java.text package.

For example, to limit the number of decimal places to two, we can create a DecimalFormat object as

DecimalFormat df = new DecimalFormat("0.00"); and use it to format the number as

double number = 217.86726442542; System.out.println("Number: " + df.format(number) );

Use the package java.text to display your converted values to two decimal places.

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

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions

Question

Exude confidence, not arrogance.

Answered: 1 week ago

Question

Make arguments for the union and for the employer.

Answered: 1 week ago