Lab 1 – Calculate the Length of a Year on Another Planet
On a planet in our solar system, a ‘year’ is the amount of time it takes for the planet to revolve around the Sun. The Earth revolves around the Sun in one Earth year. Other planets take shorter or longer periods to revolve around the Sun.
We can use a simple formula (based on Kepler’s Third Law) to calculate the length of a year on another planet in Earth years.
pyears = sqrt(distance ^ 3)
pyears: number of Earth years for the planet to revolve around the Sun
distance: distance of planet from Sun in Astronomical Units (AU’s)
Note: the Earth is exactly one AU from the Sun.
Write a program that asks the user for the name of a planet and the distance of that planet from the Sun in AU’s. The program should than calculate a ‘year’ on that planet in Earth years and output the information to the user. Use user friendly prompts. Be sure to include a comment at the beginning of the program with your name, date, and a short description of the program.
Here’s some information about the solar system to help test your program.
|Planet||Distance (in AU)||Period of Revolution (i.e. ‘year’)|