Question: In this assignment you will write a small C program. Your program should compile correctly and produce the specified output. Please note that the computer

In this assignment you will write a small C program. Your program should compile correctly and produce the specified output. Please note that the computer program should comply with the commenting and formatting rules as has been done in class. For example, there should be a header for the whole program that gives the authors name, class name, date, and description. End braces should be commented, and there are alignment and indenting requirements as discussed. Please ask if you have any questions.

------------------------------------------------------------------------------------------------------------------------------------------------------------

The program will read a file with city information that includes city id, location(x,y) and city name; after reading the file the program will display a menu; using the menu, the user will choose two cities (either by id or name) and compute the linear (Euclidean) distance between the two chosen cities. Given a file with the following format: int float float string For example: 1 42.4 73.45 Albany, N.Y. 2 35.05 106.39 Albuquerque, N.M. 3 35.11 101.5 Amarillo, Tex. 4 61.13 149.54 Anchorage, Alaska 5 33.45 84.23 Atlanta, Ga. 6 30.16 97.44 Austin, Tex. Table 1: File Format Where - Column 1 is the ID Unique integer value. It may not be continuous - Column 2 is X coordinate, - Column 3 is Y coordinate, - Column 4 is city name. It may include state/province and country. Write a program to 1) Read the data from the input file, a. Store the information using parallel arrays: one array for ID, one for X coordinates, one for Y coordinates and one for string names. Assume that the maximum number of entries(i.e. cities) is 1000.

2) Display a menu (10 points ): a. Enter City 1 b. Enter City 2 c. Compute Distance d. Exit Notice: o Make sure your options are letters( numbers are not allowed) 3) When option a) or b) are selected, the program should determine automatically if the user entered the city id or the city name (20 points) 4) If option c) is chosen: a. Find the index for each city, either using the id array(10 points) or the city name array(35 points) b. Compute the linear distance (5 points) Deliverables You will turn in C source code file. The C source code file should: 1) Comply with all of the formatting requirements already discussed. 2) Query the user(input) 3) Display the output 4) Perform the operations described

---------------------------------------------------

attached file name: cityInfo.txt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!