Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The following is the distance chart. fromCity toCity Seattle Denver Chicago Los Angeles 1135 1016 2015 San Francisco 807 1250 2128 Portland 174 1240
The following is the "distance chart". fromCity toCity Seattle Denver Chicago Los Angeles 1135 1016 2015 San Francisco 807 1250 2128 Portland 174 1240 2121 Instruction: 1. Use Notepad to create new text file named "EX07_2.java". Enter the following two lines (be sure to replace YourFullName with your full name): // FileName: EX07_2.java // Programmer: Your FullName 2. Next to the above two lines, create a Java ArrayList of String type named "fromCity", and then use the "Add()" method to add three elements to it: "Los Angeles", "San Francisco", and "Portland". Create another Java ArrayList of String type named "toCity" with three elements: "Seattle", "Denver", and "Chicago". 3. Create a two-dimensional array of int type named "distance" whose elements are the distance as listed in the following "distance chart", in which 0, 1, 2 are indexes of rows (representing "fromCity") and columns (representing "toCity"). Be sure to make the elements using the index of [from] [to]. fromCity\toCity 0 1 2 0 1135 1016 2015 1 807 1250 2128 2 174 1240 2121 4. Ask the user to enter the name of city to "travel from", and then se the "indexof()" method find the index of the given city in the "fromCity" ArrayList. 5. Ask the user to enter the name of city to "travel to", and then se the "indexOf()" method find the index of the given city in the "toCity" ArrayList. 6. Use both indexes in the format, [from] [to], to find the distance from the "distance" array and display it. Enter the city to travel from: San Francisco Enter the city to travel to: Denver The distance is 1250 miles. Enter the city to travel from: Los Angeles Enter the city to travel to: Chicago The distance is 2015 miles. 7. Capture screen shot(s) similar to the above figure(s) and paste it to the Word document named "EX07.doc" (or .docx or .pdf).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started