Question: Problem Statement: Design a Visual C# application that will calculate and display the driving distance between two selected US cities. The application will also determine

Problem Statement: Design a Visual C# application that will calculate and display the driving distance between two selected US cities. The application will also determine the average driving time between the two cities, calculated at 47MPH (national average) and display the average driving time and the images of the two cities. Use ComboBoxes control to handle the selection of the two cities including their images and the access into a two-dimensional array to obtain the driving distance between the two cities.

Through a third ComboBox control, the application will allow for the selection of a city and display the total distances from that city to all other cities.

Array declaration is needed to store all the distances between two cities.

double[,] drivingDistancesArray = {{0, 1004, 1753, 2752, 3017, 1520, 1507, 609, 3155, 448},

{1004, 0, 921, 1780, 2048, 1397, 919, 515, 2176, 709},

{1753, 921, 0, 1230, 1399, 1343, 517, 1435, 2234, 1307},

{2752, 1780, 1230, 0, 272, 2570, 1732, 2251, 1322, 2420},

{3017, 2048, 1399, 272, 0, 2716, 1858, 2523, 1278, 2646},

{1520, 1397, 1343, 2570, 2716, 0, 860, 1494, 3447, 1057},

{1507, 919, 517, 1732, 1858, 860, 0, 1307, 2734, 1099},

{609, 515, 1435, 2251, 2523, 1494, 1307, 0, 2820, 571},

{3155, 2176, 2234, 1322, 1278, 3447, 2734, 2820, 0, 2887},

{448, 709, 1307, 2420, 2646, 1057, 1099, 571, 2887, 0}};

Pressing the Calculate button will look up the distance between the two cities from the two-dimensional array. To find the distance in the array, the row position is the SelectedIndex of the comboBoxDeparture and the column position is the SelectedIndex of the comboBoxDestination. Specifically, here are the steps that need to be accomplished.

Lookup driving distance in the two-dimensional array: the row index is determined by the comboBoxDeparture.SelectedIndex and the column index is determined by the comboBoxDestination.SelectedIndex. If the user has not selected a city, an error message should be displayed. If the user has selected the same city for both departure and destination, an error message is also displayed.

After the distance has been determined, the driving time should be computed. Statistics have determined that the national average speed that automobiles travel on highways is 47MPH. Calculate the driving time based on this speed. To find the total driving time, you need to divide the distance by 47MPH, which will give you a decimal value. The whole number part of the total driving time is the number of hours. The decimal part is a fraction of an hour and needs to be multiplied by 60 to determine the number of minutes.

Both distance and driving time (hours and minutes) should be displayed into labels. The minutes display is rounded to the nearest minute.

Selection of a city in the Departure combobox should display the image of the city in the departure PictureBox.

Selection of a city in the Destination combobox should display the image of the city in the destination PictureBox.

Selection of a city in the City for Total Distance combobox should calculate and display the sum of distances from the selected city to all cities. The display should have the sum rounded to the nearest mile and have the text miles appended.

Create and use a function for this computation named MilesAllCities.

On form load, read the names of the cities from the CityNames.txt file. Populate (add), these names to all three ComboBoxes.

Pressing the Clear button should clear all ComboBoxes, PictureBoxes, and Labels. You can clear a ComboBox by setting its SelectedIndex back to ?1.

Pressing the Exit button should close the application.Problem Statement: Design a Visual C# application that will calculate and displaythe driving distance between two selected US cities. The application will alsodetermine the average driving time between the two cities, calculated at 47MPH

rsi28 Quir 7.pa ?TS 1?lmtroduttich Te p -+ 130% Run #1 Look up City Distances Coder: Name Distance TravelBetween Cities Departure: Destination: City for Total Distance: Boston Chicago Boston Distance to All Cities 15,765 miles Distance in Miles 1004 Driving Time at 47mph 21 hrs 22 min Calculate Clear Exit rsi28 Quir 7.pa ?TS 1?lmtroduttich Te p -+ 130% Run #1 Look up City Distances Coder: Name Distance TravelBetween Cities Departure: Destination: City for Total Distance: Boston Chicago Boston Distance to All Cities 15,765 miles Distance in Miles 1004 Driving Time at 47mph 21 hrs 22 min Calculate Clear Exit

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!