Question

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

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 NOT enter 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!)

Capture.PNG

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Write a program to allow the user to calculate the distance between cities on a map.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • (The cities.txt file is just a list of almost 30,000 cities and their distance from Charlotte)...

    (The cities.txt file is just a list of almost 30,000 cities and their distance from Charlotte) Your goal is to print the cities in United States sorted in the increasing order of distance from Charlotte. Download from Canvas the text file (cities.txt containing the latitude and longitude information of nearly 30,000 cities in the United States. Calculate the distance from Charlotte to each of these cities. Sort the cities in ascending order of distance, and print the sorted list along...

  • *In Python please***** This program will display some statistics, a table and a histogram of a...

    *In Python please***** This program will display some statistics, a table and a histogram of a set of cities and the population of each city. You will ask the user for all of the information. Using what you learned about incremental development, consider the following approach to create your program: Prompt the user for information about the table. First, ask for the title of this data set by prompting the user for a title for data, and then output the...

  • Problem: Write a program to calculate the force of gravitational attraction between two objects of known...

    Problem: Write a program to calculate the force of gravitational attraction between two objects of known mass at a known distance. Use the formula developed by Isaac Newton known as Law of Universal Gravitation. F G*m *m2/d2 Where F (Force of gravity) is expressed in Newtons (N), mi and m2 (masses of the objects) are expressed in kilograms (kgs) and d (distance from the center of one object to the center of the other) is expressed in meters (m) and...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • Write a program that allows the user to enter a series of exam scores. The number...

    Write a program that allows the user to enter a series of exam scores. The number of scores the user can enter is not fixed; they can enter any number of scores they want. The exam scores can be either integers or floats. Then, once the user has entered all the scores they want, your program will calculate and print the average of those scores. After printing the average, the program should terminate. You need to use a while loop...

  • (C++ Program) 1. Write a program to allow user enter an array of structures, with each...

    (C++ Program) 1. Write a program to allow user enter an array of structures, with each structure containing the firstname, lastname and the written test score of a driver. - Your program should use a DYNAMIC array to make sure user has enough storage to enter the data. - Once all the data being entered, you need to design a function to sort the data in descending order based on the test score. - Another function should be designed to...

  • Exercise 6: Program exercise for 2D List Write a complete Python program including minimal comments (file...

    Exercise 6: Program exercise for 2D List Write a complete Python program including minimal comments (file name, your name, and problem description) that solves the following problem with the main function: Problem Specification: The following code reads values from the file object infile and stores them in the 2d list table2: (It assumes that each line contains values of elements in each row and the values are whitespace separated.) table2 = [] for line in infile: row=line.split() intRow = []...

  • In Python Calculator Write a program that allows the user to enter two numbers and then...

    In Python Calculator Write a program that allows the user to enter two numbers and then adds, subtracts, divides or multiplies them when the user clicks on the appropriate button. Make sure you have a Quit button. Modification and requirements”: _____Window title should be  your name Calculate self.main_window.title("?????") _____Labels - change the attributes of the color, font, size and bold the answerExample self.label = tkinter.Label(self.main_window, \ text='?????????!', font=(" should Arial", 12, "bold"), fg="blue", bg="pink")Tip: choose a color from the...

  • Homework IX-a Write a program that opens a text file, whose name you enter at the keyboard You wi...

    Homework IX-a Write a program that opens a text file, whose name you enter at the keyboard You will be using the file text.txt to test your program. Print out all of the individual, unique words contained in the file, in alphabetical order Print out the number of unique words appearing in text.txt. Call your program: YourName-HwrklXa.py Make sure that your name appears as a comment at the beginning of the program as well as on the output display showing...

  • The Acme Trucking company has hired you to write software to help dispatch its trucks. One important element of this sof...

    The Acme Trucking company has hired you to write software to help dispatch its trucks. One important element of this software is knowing the distance between any two cities that it services. Design and implement a Distance class that stores the distances between cities in a two-dimensional array. This class contains the following required data members and methods: Required Data Members: String[] cities; //it is used to store city names int[][] distance; // this 2-D array repreents distance between two...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT