UMBC CMSC104

CMSC104, Summer 2002

Programming Project #4

Bode's Law Revisited

Out: Thursday, July 11, 2002
Due: Thursday, July 18, 2002 before midnight


The Objective

This project will give you practice using arrays and passing arrays to functions. You will be able to modify your code from Project 3.

The Background (Same as Project #3)

Mathematicians and other scientists find unexpected applications for power series approximation. In 1772, the astronomer J. E. Bode proposed a rule for calculating the distance from the sun to each of the planets known at that time. To apply that rule, which subsequently became known as Bode's law, you begin by using the sequence:

b1 = 1, b2 = 3, b3 = 6, b4 = 12, b5 = 24, b6 = 48

where each subsequent element in the sequence is twice the preceding one. It turns out that an approximate distance to the ith planet can be computed from this series by applying the formula

d i = ( 4 + b i ) / 10

The distance is given in astronomical units; an astronomical unit (AU) is the average distance from the sun to the earth, which is approximately 93,000,000 miles. Except for a disconcerting gap between Mars and Jupiter, Bode's law gives reasonable approximations for the distances to the seven planets that were known in Bode's day:

Distance from the Sun

Mercury      0.5 AU   4.650000e+07 miles
Venus        0.7 AU   6.510000e+07 miles
Earth        1.0 AU   9.300000e+07 miles
Mars         1.6 AU   1.488000e+08 miles
?            2.8 AU   2.604000e+08 miles
Jupiter      5.2 AU   4.836000e+08 miles
Saturn      10.0 AU   9.300000e+08 miles
Uranus      19.6 AU   1.822800e+09 miles

Concern about the gap in the sequence led astronomers to discover the asteroid belt, which they decided was left over after the destruction of a planet that had once orbited the sun at the distance specified by the missing entry in Bode's table.

The Task

You are to expand on the program you wrote for Project 3 . Instead of calculating each distance and printing out a table of all the planets, you are going to store all of the values in arrays. You will need two arrays, one to store the AU values and one to store the miles values. You will display a menu to the user. The user can then select which planet's information he/she would like to see.

You'll be expected to write a minimum of seven functions, other than main, for this project.

Here are the function prototypes:

Function Descriptions:


Sample Output

[Your explanation to the user goes here]. 1) Mercury 2) Venus 3) Earth 4) Mars 5) Asteroid Belt 6) Jupiter 7) Saturn 8) Uranus 9) Quit Which planet's information would you like to see? 1 Mercury is the closest planet to the Sun. It is 0.5 astronomical units, which is 4.650000e+07 miles, from the Sun. 1) Mercury 2) Venus 3) Earth 4) Mars 5) Asteroid Belt 6) Jupiter 7) Saturn 8) Uranus 9) Quit Which planet's information would you like to see? 2 Venus is the second planet from the Sun. It is 0.7 astronomical units, which is 6.510000e+07 miles, from the Sun. 1) Mercury 2) Venus 3) Earth 4) Mars 5) Asteroid Belt 6) Jupiter 7) Saturn 8) Uranus 9) Quit Which planet's information would you like to see? 3 Earth is the third planet from the Sun. It is 1.0 astronomical units, which is 9.300000e+07 miles, from the Sun. 1) Mercury 2) Venus 3) Earth 4) Mars 5) Asteroid Belt 6) Jupiter 7) Saturn 8) Uranus 9) Quit Which planet's information would you like to see? 4 Mars is the fourth planet from the Sun. It is 1.6 astronomical units, which is 1.488000e+08 miles, from the Sun. 1) Mercury 2) Venus 3) Earth 4) Mars 5) Asteroid Belt 6) Jupiter 7) Saturn 8) Uranus 9) Quit Which planet's information would you like to see? 5 There is a gap in between Mars and Jupiter. It was discovered to be an asteroid belt. It is 2.8 astronomical units, which is 2.604000e+08 miles, from the Sun. 1) Mercury 2) Venus 3) Earth 4) Mars 5) Asteroid Belt 6) Jupiter 7) Saturn 8) Uranus 9) Quit Which planet's information would you like to see? 9 Thank you for using this program!

Submitting the Program

To submit the file you should use the command:

submit cs104 Proj4 proj4.c

You can check your submission by using the command:

submitls cs104 Proj4


Last Modified: Thursday, 11-Jul-2002 12:19:28 EDT
Thursday, 11-Jul-2002 12:19:28 EDT