[an error occurred while processing this directive]

CMSC 201
Programming Project One

Bode's Law

Out: Thursday 2/12/98
Due: Midnight Thursday 2/26/98

The Objective

The objective of this assignment is to get you started writing programs in C in the UNIX environment. This project will give you practice using loops, the switch, mixing data types and writing functions.

The Background

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 write a program that calculates each of the distances in both astronomical units using Bode's formula and the number of miles (shown in exponential notation), where 1 AU = 93,000,000 miles. You will first need to calculate the value of the current term in the series. Do this within a function called GetTermValue. You are not allowed to #define the values of the terms of the sequence, or hard code these values in any way. Your program should print out a table exactly like the one shown above.

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

Here are the function prototypes:

Function Descriptions:

Submitting the Program

To submit the file you should use the command:

submit cs201 proj1 proj1.c

You can check your submission by using the command:

submitls cs201 proj1 [an error occurred while processing this directive]Thursday, 12-Feb-1998 13:00:02 EST