Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started