Question
Update: I just placed the airport.txt into the same folder as flightfares but still getting: Error: Could not find or load main class Dijkstra Caused
Update: I just placed the airport.txt into the same folder as flightfares but still getting:
Error: Could not find or load main class Dijkstra Caused by: java.lang.ClassNotFoundException: Dijkstra
Help most appreciated!
urgent Java programming help please! Please let me know how I should try the code out in Eclipse such as paste everything as is into one section or what I should do (try putting into the same folder as the project and so on). Thank you in advance!
airport.txt
ATL BOS 250 DFW 250 MOB 59 AUS DFW 59 HOU 59 SAT 59 BOS ATL 250 DFW 250 DFW ATL 250 AUS 59 BOS 250 HOU 128 LAX 1000 LIT 59 MSY 128 OKC 59 SHV 59 SFO 1200 HOU AUS 59 DFW 128 SAT 59 LAX DFW 1000 SFO 100 LIT DFW 59 MOB ATL 59 MSY DFW 128 OKC DFW 59 SAT AUS 59 HOU 59 SFO DFW 1200 LAX 100 SHV DFW 59
Here is a chunk that might help! I am not sure how to do package dijkstra;
package dijkstra;
import java.io.File; import java.util.ArrayList; import java.util.Scanner;
public class FlightFares {
int nodes; /o of items private double fare_matrix[][]; //weighted matrix private String codes[]; //store code names for airports private double distance[]; //stores all fares from source to all remaining airports
public static void main(String args[]) { FlightFares ob = new FlightFares(); //creaing object String fileName = "airports.txt"; //filename
//reading file and generating matrix form of fares try { ob.readFile(fileName); //readfile function reads file and generates matrix } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }
/*for (String str : ob.codes) { System.out.println(str + " "); }
for (double str[] : ob.fare_matrix) { for (double fare : str) { System.out.print(fare + " "); } System.out.println(); } */ //calling calc() method with source name DFW String source = "DFW"; ob.calc(ob.nodes, source); System.out.println("The Shortest Path from Source \t" + source + "\t to all other vertices are : "); for (int i = 0; i
} } //function to calculate minimum fares public void calc(int n, String str) { int flag[] = new int[n]; int i, minpos = 0, k, c; double minimum; int s = getIndex(str); for (i = 0; i
}
//function to read data from file and generate weighted matrix public void readFile(String FileName) throws Exception { File F; F = new File(FileName); ArrayList list = new ArrayList(); Scanner S = new Scanner(F); System.out.println(" loading... [" + FileName + "] and reading data... ");
while (S.hasNextLine()) { String[] splited = S.nextLine().trim().split("\\s+"); list.add(splited[0].toUpperCase()); } S.close();
//initiating class properties nodes = list.size(); fare_matrix = new double[nodes][nodes]; distance = new double[nodes]; codes = list.toArray(new String[list.size()]);
S = new Scanner(F);
while (S.hasNextLine()) { String[] splited = S.nextLine().trim().split("\\s+"); int row = getIndex(splited[0]), column = -1; for (int i = 1; i
} } for (int i = 0; i
}
//method to get index value of this string from codes matrix public int getIndex(String str) { for (int i = 0; i
}
Project5 See folders you viewed previously Downloads Desktop Documents iCloud Drive AirDrop java CLASS TXT dijkstra.java FlightFares.class airports.txt Devices Remote Disc Eclipse Eclipse* Tags GreenStep 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