Programming Project #7Bode's Law Revisited Due: Wednesday, December 12, 2001 before midnight
The ObjectiveThis project will give you practice using arrays and passing arrays to functions. You will be able to modify your code from Project 6. The Background (Same as Project #6)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 TaskYou are to expand on the program you wrote for Project 6 . 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: void PrintExplanation (void); void PrintMenu (void); int GetValidChoice(void); int GetTermValue (int index); void FillAUArray (double au[], int size); void FillMilesArray(double miles[], double au[], int size); void PrintPlanetInfo (int choice, double au[], double miles[]); Function Descriptions:
Sample OutputSubmitting the ProgramTo submit the file you should use the command: submit cs104_09 Proj7 proj7.c You can check your submission by using the command: submitls cs104_09 Proj7 |