Write a program to allow the user to calculate the distance between cities on a map. Sounds pretty complicated, eh? Don't worry, we'll make a few simplifications here: The distances are calculated in map units on the 2D map. Each city is given a set of coordinates relative to some point on the map. We'll call this origin (0,0). There can only be a finite number of cities in the system at a given time (you decide this maximum). But in order to make the system useful, we'll have to add a few other features: Each city has a name in addition to its coordinates (you can assume a maximum length for these names; but they must be able to hold spaces: Los Angeles, New York, etc.). The user selects what action to take from a menu: 1) Enter city Information 2) calculate Distance between two cities 3) Print All cities 4) Quit Make sure you allow them to choose their options by both the number and the capitalized letter(s) of the choice. They cannot calculate a distance until at least two cities have been entered. When they have exactly two cities, assume they are the ends and print their distance. When they have more than two cities, show them the list of cities and have them pick the two cities to calculate the distance between. Don't let them choose the same city for both ends of the 'trip'. If your list is full and they choose to enter another city, have them choose to either NOTenter the new city or to overwrite one of the earlier cities (they choose which one). Print the list of cities for them to choose from. (Remember, you still can't exceed your maximum list size!)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a program to allow the user to calculate the distance between cities on a map.

Sounds pretty complicated, eh? Don't worry, we'll make a few simplifications here:

  • The distances are calculated in map units on the 2D map.

  • Each city is given a set of coordinates relative to some point on the map. We'll call this origin (0,0).

  • There can only be a finite number of cities in the system at a given time (you decide this maximum).

But in order to make the system useful, we'll have to add a few other features:

  • Each city has a name in addition to its coordinates (you can assume a maximum length for these names; but they must be able to hold spaces: Los Angeles, New York, etc.).

  • The user selects what action to take from a menu:

    1) Enter city Information
  • 2) calculate Distance between two cities 3) Print All cities
  • 4) Quit

    Make sure you allow them to choose their options by both the number and the capitalized letter(s) of the choice.

  • They cannot calculate a distance until at least two cities have been entered.

  • When they have exactly two cities, assume they are the ends and print their distance.

  • When they have more than two cities, show them the list of cities and have them pick the two cities to calculate the distance between. Don't let them choose the same city for both ends of the 'trip'.

  • If your list is full and they choose to enter another city, have them choose to either NOTenter the new city or to overwrite one of the earlier cities (they choose which one). Print the list of cities for them to choose from. (Remember, you still can't exceed your maximum list size!)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education