Please provide the answer in Java 1. Consider the following scenario: The Colonel Motors Corporation of Frankfort,...

60.1K

Verified Solution

Question

Programming

Please provide the answer in Java

1. Consider the following scenario: The Colonel MotorsCorporation of Frankfort, Kentucky has produced a new line ofvehicles which require chicken droppings for fuel. Because of thisunusual fuel requirement, there are only certain fueling stationsin the country where the vehicles can be refilled. Thus, to getfrom one place to another, an owner must plan a route that ensuresthat he can get refills along the way. The Colonel MotorsCorporation has hired Professor Sanders of the Kentucky Instituteof Technology as a consultant to prepare an online route-findingservice. To use the computerized service, an owner will enter thedriving range of his vehicle (the distance the vehicle can go on asingle fill-up), the \"distance to empty\" (the distance the vehiclecan go with the fuel that's now in the tank), his/her initiallocation (source), and his/her desired destination. The servicewill either respond with a shortest route from the source to thedestination such that the owner never runs out of fuel, or it willdeem that no such route exists. Model the professor's problem interms of a weighted, directed graph in which streets are edges,intersections are vertices, and some intersections have fuelingstations, and design an efficient algorithm to solve it. Assumethat a driver's source and destination are also atintersections.

2. Choose an appropriate problem-solving technique: Select yourfavorite programming language such as C, C++, or Java. In thatlanguage, write, implement, and test an algorithm using the problemsolving technique that you chose. Analyze your implementation usingeither order notation analysis or empirical analysis. You mustprepare a separate page providing the instructions to compile andexecute your program, such as the development environment (e.g.,Visual Studio). If no such information is provided, and yourprogram fails to build and run, points will be deducted, asappropriate.

Answer & Explanation Solved by verified expert
3.9 Ratings (677 Votes)
HELLO ADDING WHOLE WORKING JAVA CODE HERE PLEASE GO TROUGH IT ONCE AND PLEASE PROVIDE ADJACENCYMATRIX IN FILE NAMED adjacencymatrixtxt HERE IS THE CODE import javaioFile import javaioFileNotFoundException import javautilArrays import javautilList import javautilScanner import javautilArrayList import javautilIterator import javautilNoSuchElementException class GraphUtility public static void mainString args TODO Autogenerated method stub try readFromFile catchException ex0 ex0toString public static void swapint array int i int j int tempO arrayi arrayi arrayj arrayj tempO Util Function public static int listToArrayList list int tempArray new intlistsize forint i 0 i listsize i tempArrayi listgeti return tempArray public static int readFuelInfo throws FileNotFoundException Scanner scan new Scannernew Filefuelstxt String strInput List arrayValues new ArrayList ifscanhasNextLine strInput scannextLine String tempValues strInputsplit forint i 0 i tempValueslength i try arrayValuesaddIntegerparseInttempValuesitrim catchException ex0 int fuelData listToArrayarrayValues SystemoutprintlnfuelDatalength 0 fuel stations ArraystoStringfuelData no fuel stations found return fuelData public static GraphData readGraph throws FileNotFoundException Scanner scan new Scannernew Fileadjacencymatrixtxt int V scannextInt scannextLine double adjacencyMatrix new doubleVV for int v 0 v V v for int e 0 e V e adjacencyMatrixve scannextDouble return new GraphDataV adjacencyMatrix class PathComponent private int s private int d public PathComponentint s int d thiss s thisd d public int getSource return thiss public int getDestination return thisd class IntermediatePath private String stringPath private IntersectionNode nodes private List    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students