Please observe the following code
Observe the last line io.execute(dt, solver);Code:Scanner input=new Scanner(System.in); System.out.println(); System.out.println("Welcome to Breadth First Search TSP Solver"); System.out.println("=========================================="); System.out.println(); System.out.println("Please select preferred distance table:"); System.out.println("\t (1) Default distance table"); System.out.println("\t (2) User defined distance table"); int selectTable=input.nextInt(); System.out.println(); if(selectTable==1){ DistanceTable dt = DistanceTable.getDefault(); }else if(selectTable==2){ DistanceTable dt = DistanceTable.userTable("test.txt"); }else{ System.out.println("Invalid input. Program terminated."); } System.out.println("Please select preferred output destination:"); System.out.println("\t (1) Monitor screen"); System.out.println("\t (2) User defined .txt file"); System.out.print("Select 1 or 2: "); int selectOutput=input.nextInt(); System.out.println(); BfsTSPSolver solver = new BfsTSPSolver(); TspIO io=new TspIO(selectOutput); io.execute(dt, solver);
When i tried to compile it says that line can't find the symbol for dt...
But isn't dt already defined in the middle with selectTable input??
What am i missing here?


Reply With Quote


Bookmarks