Create a java application

Assignment Help JAVA Programming
Reference no: EM13784573

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:

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 NewYork
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: EM13784573

Questions Cloud

Discuss how these advances have changed : Write a 500-600 word paper identifying some of the technology used by law enforcement in carrying out their duties. In your paper: Discuss how these advances have changed the way police do business
Stock market and the bond market : Understanding the differences between the stock market and the bond market is essential to managing corporations and investing. In your discussion, answer the following questions:
Calculating mortgage payments : What is 1 mistake people make when calculating their mortgage payments? Explain your answer.
What is hamiltons estimated stock price today : What is Hamilton's estimated stock price today - if you bought the stock at Year 0, what your expected dividend yield and capital gains for the upcoming year?
Create a java application : 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.
Define ethical issues relating to marketing and advertising : Research three to five (3-5) ethical issues relating to marketing and advertising, intellectual property, and regulation of product safety and examine whether PharmaCARE violated any of the issues in question
Intrinsic or extrinsic factors of future career : How will recognizing these factors keep you motivated as you move toward your career goals?
Business policy and strategy : Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 B..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a dim statement that declares a myfriend variable

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

  Using notepad that implements a basic text analyzer

Write a Java application using Notepad that implements a basic Text Analyzer.

  Allow the user to display a work history report

The 'report screen' shall:Allow the user to display a work history report for an individual or for all employees for the two weeks prior to the report request.

  Write the code1 one argument used to justify the fact that

write the code1. one argument used to justify the fact that the stack data structure in the standard library does not

  Prepare a second class to test the receipt class

Prepare a second class to test the receipt class - Make this program using java programming. Make this application in simple way.

  Creates a file called "grades.txt" with 1000 lines

Write a program that creates a file called "grades.txt" with 1000 lines. Each line in the "grades.txt" file will consist of a student's first name, last name, graduating year(2013,2014,2015), and grade. the student's first name and last name for t..

  Object from question 1 manage its display

Write a Java statement to have the object from question 1 manage its display area by dividing it into 3 rows which have 4 columns each.

  Part 1product maintenanceyoull create a series of pages

part 1product maintenanceyoull create a series of pages that allow you to add update or delete a product thats

  Implements the measurable interface

Implement a class Quiz that implements the Measurable interface. A quiz has a score and a letter grade (such as B+).

  Write down ijvm code to remove top two words from stack

Write down IJVM code which will remove these top two words, multiply and put their product back on stack. You are allowed to use existing IJVM instructions only.

  What could you do to kill more mutants

What are the implications related to suite of unit test cases when some mutants are not killed and What could you do to kill more mutants?

  Part-2write a program that will perform some of the basic

part-2write a program that will perform some of the basic tasks accomplished by a file integrity checker such as

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