Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

02. (a) Define a class named Planet, which contains two instance variables that store the name of a planet (name) and the number of days

image text in transcribed

image text in transcribed

02. (a) Define a class named Planet, which contains two instance variables that store the name of a planet (name) and the number of days the planet takes to travel around the Sun (travelDays). Write a method printPlanet O which displays the planet's details. In addition, write a test class to test your Planet class. (6 marks) le output for driver Ester the Enter the days: 36 Planet Nase: Earth Days:6 Process conpleted (b) Add a calculateAge ) method to your Planet class which calculates a person's age on that planet. Use the following formulac age on the planet (age *365)/ travel Days; The calculateAge ) method should receive an argument that represents the age on Earth. Modify your test class to obtain user input on their age on Earth and test your calculateAge ) method. (4 marks) PlanetTravel Davs Venus 255 ter 4380 Saturn 10767 le output for driver Ester your age on Earth Enter the tavel days tor Venus 255 Planet ne Teus Travel Days: 2S ge on Venus 28 Add the following constructors to your Plan .A no-arg constructor to initialize the value of name to "Earth and et class: travelDays to 365 A constructor with two parameters. Modify your test class to test the constructors that vou have defined

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

More Books

Students also viewed these Databases questions

Question

=+j Enabling a productive global workforce.

Answered: 1 week ago