Question Write a C program A file contains the services available along Highway
ID: 649253 • Letter: Q
Question
Question
Write a C program
A file contains the services available along Highway 401. Each entry details the exit number followed by a numerical value detailing the services. The exit number corresponds to the distance in kilometers from the Michigan border in Windsor. The services numerical code can be decoded using the following key:
1 = gas available
2 = food available
4 = lodging available
8 = hospital available
For example, entries in the file such as 90 3 164 11 232 2 328 0 mean that exit 90 has gas and food (2+1), that exit 164 has a hospital, food and gas (8+2+1), that exit 232 has food only (2), and that exit 328 has no services (0). Your first task is to read the entire highway file into an array, the subscript can indicate the exit number and the cell content the services code (you are free to use any data structure that actually works). Note that the last exit near the Quebec border is exit 825. You create your own data file with 20-50 sample exits.
Your program must contain a menu that offers the following options to the user:
1. An option that displays the list of all exit numbers that have hospitals.
2. An option that asks the user for a location in kilometers (from the Michigan border) and gives the two closest gas stations (1 eastbound, 1 westbound) with the direction clearly indicated and the actual distance to drive.
3. An option that asks the user for a location in kilometers (from the Michigan border) and gives the two closest exits (1 eastbound, 1 westbound) that have gas, food and lodging with the direction clearly indicated and the actual distance to drive. Important: You must use the file input protocol (FILE / fopen / fscanf / fclose) and you must name your data file hwy401.txt (You create your own file using the the date structure provided above). Your name(s) must appear at the top when you run the program. Failure to abide by these instructions will result in a zero grade.
Explanation / Answer
x.x
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.