Write a program that processes data files produced by an embedded system connected to a GPS device and calculates the weighted average altitude and average speed for the recorded trip. Note that the data may not be sampled uniformly and you are requested to use the time increment as the weighting variable.
Please analyze the data format of the two provided files: data_bike.txt and data_fly.txt. Observe the columns where altitude A (always in feet), distance increment D (in feet or miles, must convert all to miles), and time. The time increment is specified in hours:minutes:seconds in between columns for distance and speed. Lines with incomplete readings or with a different formatting should be ignored. Otherwise, after extracting A, D and T proceed with incremental calculations.
Calculate the weighted average altitude using time as weight, and average speed in mph by dividig total distrance traveled (add up leg distances) by total time traveled (add up leg times)
In your program ask the user to enter the name of the file to be processed. Run your program two times in order to process both provided files. You may want to (but you do not have to) use the file parsing example analyzed in class as your starting point.
Write a program that processes data files produced by an embedded system connected to a GPS device and generates a data file to be imported to a stationary training bicycle.
Please analyze the data format of the two provided files: data_bike.txt and data_fly.txt. Observe the columns where altitude A (integer, always in feet), distance increment D (integer or double but read always as double, in feet or miles, must convert all to miles or to feet), and the time increment T (three integers, always in format HH:MM:SS). Lines with incomplete readings or with a different formatting should be ignored. Otherwise, after extracting A, D and T proceed with calculations. The exception is the very first data line where you need to extract only the altitude.
Calculate the incline for the given segment by converting the distance traveled to feet. Calculate the incline in degrees as defined by arcsin of the difference between the last and the second most recent altitude divided by the distance traveled on that segment. Convert the angle from radians to degrees. Note that you need to use the current line and the altitude saved from the previous line in order to complete the calculations.
For each line processed from the source file write one line with results to the destination file. The destination file should have three columns in the following order: distance traveled on the segment, incline of the segment in degrees, and total time of the segment in seconds. Do not print units, just numbers.
In your program ask the user to enter the name of the file to be processed and the name for the file to write to. Run your program two times in order to process both provided files. You may want to (but you do not have to) use the file parsing example analyzed in class as your starting point.
Implement and test the function that receives a possibly incomplete URL (universal resource locator) string and returns three strings: the locator that splited into three basic components: type, host name and page location according to the definition provided by the enclosed examples. Test your function using all of these examples and some more data of your own choice.
Sample data:
| URL (value received) | type (value returned) | host (value returned) | page (value returned) |
|---|---|---|---|
| http://www.bradley.edu/student.html | http | www.bradley.edu | /student.html |
| http://cegt201.bradley.edu/ | http | cegt201.bradley.edu | / |
| http://bobcat.bradley.edu | http | bobcat.bradley.edu | / |
| www.weather.com | http | www.weather.com | / |
| http://www.weather.com/weather/local/USIL0935 | http | www.weather.com | /weather/local/USIL0935 |
| sant | http | sant | / |
| ftp://ftp.isi.edu/in-notes/rfc2397.txt | ftp | ftp.isi.edu | /in-notes/rfc2397.txt |
| TYPE://HOST/PAGE/LOCATION | TYPE | HOST | /PAGE/LOCATION |
You can asume that either TYPE:// exists or is left out entirely. If so - return "http" as the default type. The /PAGE either exists or is left out. If so - return "/" as the default page location. Assume that the HOST is always present. Please ask the instructor if you have any doubts about interpreting the functional definition above.
A suggested test program is provided for your convenience.
Disclaimer: The URL format described above is only a very simplified version of an actual data format that is used to define the location of some data in the Internet. If you are interested read more about URL (optional).