Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem statement: Given an input file (cityInfo.txt) with the following format: i.e.: 52 58.18 134.24 Juneau, Alaska 53 39.06 94.35 Kansas City, Mo. 54 24.33

Problem statement: Given an input file (cityInfo.txt) with the following format: i.e.: 52 58.18 134.24 Juneau, Alaska 53 39.06 94.35 Kansas City, Mo. 54 24.33 81.48 Key West, Fla. Where each row ( entry ) represents the city ID, followed by x and y coordinates, and a string label for the city name. The number of entries is NOT fixed (i.e. different files, may have different number of rows/entries) a) Write a function to count the number of entries in the input file (6 points) b) Define a structure to hold the information of a single entry i. int id, double xcoor, double ycoord and string cityname (5points) ii.Write a function member to display the struct data. (5 points) c) Using the number of entries (n) from a), and allocate memory for all of them using the structure in b) (5 points) d) Display a menu to: 1)Sort by city id (10 points) 2)Find the linear distance between two cities(enter city ids) (10 points) 3)Find the linear distance between two cities(enter city names) (20 points) 4)Max and Min distance (5 points) 5)Exit Notice that: For option 2 and 3 Make sure the two different cities Option 4, given one city name or id, it computes the distance to all the other cities, and finds the closest and farthest cities(min and max distance) and displays their respective information Hints: you can use strcmp for string comparison.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2023 Workshops 34th International Conference Dexa 2023 Penang Malaysia August 28 30 2023 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Maqbool Khan

1st Edition

303139688X, 978-3031396885

More Books

Students also viewed these Databases questions

Question

2. How is it that some organizations succeed during a recession?

Answered: 1 week ago