Create a java application named distancecalculator

Assignment Help JAVA Programming
Reference no: EM131308498

Java Application - DistanceCalculator

Create a Java application named DistanceCalculator.java to solve the following problem.

An application is needed to allow a user to enter two cities and display the distances between them.

A text file named CityDistances.txt contains the names of cities and the distances between each city. The file has the following contents:

7
Chicago,0,983,787,714,1375,967,1087
Boston,983,0,214,1102,1763,1723,1842
New York,787,214,0,888,1549,1548,1627
Atlanta,714,1102,888,0,661,781,810
Miami,1375,1763,1549,661,0,1426,1187
Dallas,967,1723,1548,781,1426,0,239
Houston,1087,1842,1627,810,1187,239,0
Notice that the file tokens are delimited by commas.

The first number in the file is the number of cities. The next lines contain the city names and the distances between cities that can be used to create a two dimension array to model the distance table shown on the previous page.

Your application should read the cities into a one dimensional array and the distances into a two dimensional array.

After the arrays are created, display the number of cities and a list of cities and then prompt the user to enter two cities and then display the distances between the two cities. Validate the user input to not allow invalid cities to be entered. Create a loop to continue prompting until the user wants to exit the program.

Use fields to hold the city names array and the distances array.

Use modular programming. I suggest a method to load the arrays from the file, and a method to retrieve the city numbers and display the distance.

Program output might look like this:

Number of cities 7
City number 1 Chicago
City number 2 Boston
City number 3 New York
City number 4 Atlanta
City number 5 Miami
City number 6 Dallas
City number 7 Houston

Distance from city number: 2
To city number: 5
Boston to Miami 1763 miles
Continue (yes/no)yes

Distance from city number: 1
To city number: 7
Chicago to Houston 1087 miles
Continue (yes/no)no
Name the Java Class: DistanceCalculator

Reference no: EM131308498

Questions Cloud

Find the size of a block when one address in the block : Write a method in Java to find the last address in the block when one of the addresses in the block is given as a string representing a CIDR notation.
Will the bank likely procreed with branch office project : Miami savings bank is considering the establishment of a new branch office at the corner of 59th street and collins ave. The savings association economics department projects annual operating revenues of $1.6m from fee incone and annual baranch opera..
Understand the difference between leadership and management : 1. Is it important for you as a manager to understand the difference between leadership and management? Explain your answer. 2. What is the difference between the "situational approach" and "trait approach" to leadership? What approach seems to hav..
Write a function that accepts as arguments : Write a function that accepts as arguments the following: A) An array of integers B) An integer that indicates the number of elements in the array The function should determine the mode of the array.
Create a java application named distancecalculator : Create a Java application named DistanceCalculator.java to solve the following problem. An application is needed to allow a user to enter two cities and display the distances between them.
Is npv very much sensitive to the changes in the fixed costs : CB3410, Financial Management Assignment. How much in percentage of NPV changes in response to the increase/decrease in fixed costs? Plot NPV values for the different levels of fixed costs. Is NPV very much sensitive to the changes in the fixed cos..
How does the server know when all headers arrived : When an HTTP server receives a request message from an HTTP client, how does the server know when all headers have arrived and the body of the message is to follow?
Write a dim statement that declares a myfriend variable name : Write a Dim statement that declares a MyFriend variable named school. Write an assignment statement that assigns the value in the txtFirst control to the strFirst member.
Why should they be put in place : What basic principle of constitutional law must a police officer, but not always a probation officer, follow when conducting an ethical and legal search of a probationer's house? Explain why this law is applicable to this situation.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create simple java program that determine cost of insurance

Need to create a simple Java program that determines cost of insurance by including any additional person based on age (thus questions regarding age and how many people apply to each category as far as age should be included)

  Write a recursive method to compute the following series

Write a recursive method to compute the following series.

  Create a class - constructor for a region

The skeleton provides you with several HTML pages and associated JavaScript and CSS files representing the structure of the app. You will need to implement the logic and functionality for each of these pages - demonstrate how to change from one pag..

  Analyze some of the limitations a web designer should aware

Analyze some of the limitations a Web designer should be aware of before adding JavaScript to a Website. Determine if these limitations outweigh the benefits of using JavaScript. Explain your decision.

  Write a java program that uses the elapsed time

Write a Java program that uses the elapsed time for an event in second and then outputs the elapsed time in hours, minutes and seconds. (For example, if the desired time is 9630 seconds, then the output is 2: 40: 30)

  Program buttons that implements a window with three button

Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter

  Implement the jvm dload instruction for the mic-two

Implement the JVM DLOAD instruction for the Mic-2. It has a 1-byte index and pushes the local variable at this position onto the stack. Then it pushes the next higher word onto the stack as well.

  How are they used in javadoc comments

What is a tag and how are they used in Javadoc comments?

  Practice of using a network of remote servers

What is the name given to the practice of using a network of remote servers hosted on the Internet to store, manage, and process data, rather than a local server or a personal computer.

  How array is declared and initialized in java

What is a Java applet - how array is declared and initialized in Java and what are the access control attributes in Java?

  Discuss the use of arrays in java programs

Discussion Question: Discuss the use of arrays in Java programs versus the use of regular variables

  Write a method compact that removes all zeroes

Write a program that reads a text file (compact.txt) and stores the integers in an array.  Your instructor will provide this text file.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd