homework10-godara

# homework10-godara - ECE 1574 Homework Set#10 Problem...

This preview shows pages 1–3. Sign up to view the full content.

ECE 1574 Homework Set #10 Problem Solving with C++ Due date: Monday evening, 4/5/10 by 11:55 p.m. This assignment is to be done individually Complete the lab exercise and answer questions 1 and 2 during the lab session. Answer the other questions later. LAB EXERCISE Write, compile, test and execute a program which does the following. From a file “data.txt”, reads in and stores as a linked list on the heap a series of latitude-longitude pairs, with south latitudes and west longitudes represented as negative numbers, where the format of “data.txt” resembles 43.6 -116.2 47.6 -122.3 40.8 -111.9 and so forth. (Observe incidentally that the latitudes and longitudes listed happen respectively to be those of Boise, Seattle and Salt Lake.) After storing the complete linked list, for each member of the list, calculates the average direct (not great-circle) distance in miles from Virginia Tech of the several latitude-longitude pairs from Virginia Tech—whose latitude and longitude respectively are 37.2 and -80.4. (To calculate the direct distance, the computer should convert each latitude-longitude pair into x-y-z coordinates, with the Cartesian origin at the earth’s center and the z -axis running through the earth’s poles, then apply the Pythagorean theorem. The computer will need to know that the earth’s radius is 3959 miles. As a check case, the direct distance of Boise from Virginia Tech happens to be 1900 miles. Note that it is unnecessary to store the several distances merely to compute an average: it suffices to keep a running total.) Properly deletes the entire linked list. (Beware: there is a wrong way and a right way to do this. Given a user-defined object on the heap which contains a pointer, if one needs the address stored in the pointer, one must copy the address to a safe location before deleting the object, not after.) Outputs the average distance. For data, use the latitudes and longitudes according to http://www.infoplease.com/ipa/A0001796.html of the following places: Boise; Seattle; Salt Lake; Idaho Falls; Cheyenne; Helena; Denver. REQUIREMENTS

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
1. Write the program as a single file, but otherwise apply everything you have learned to date about good C++ style. For instance, present the earth’s radius and other constants together at the top of the program as symbolic parameters; don’t embed them in the code. Let the code which calculates the direct distance between a pair of points on the earth be a function; and so on. By this point in the term, you are expected to show good style without being told explicitly how; so, use your best judgment, and ask questions if they arise. 2. Do not use the standard library’s pow() function for any purpose.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 10

homework10-godara - ECE 1574 Homework Set#10 Problem...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online