Question: [JAVA][FIX ERRORS] import java.util.*; import java.lang.*; import java.io.*; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; public class Exercise extends JFrame { public static void main(String[] args)

[JAVA][FIX ERRORS]

import java.util.*; import java.lang.*; import java.io.*; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel;

public class Exercise extends JFrame {

public static void main(String[] args) throws FileNotFoundException {

Scanner input = new Scanner(System.in); System.out.print("Enter a file name: "); File file = new File(input.nextLine());

if (!file.exists()) { System.out.println("File does not exist"); System.exit(0); }

System.out.print("Enter two vertices (integer indexes): "); int vertex1 = input.nextInt(); int vertex2 = input.nextInt();

Scanner inFile = new Scanner(file); // Read the number of vertices String s = inFile.nextLine(); int numberOfVertices = Integer.parseInt(s); System.out.println("The number of vertices is " + numberOfVertices);

List list = new ArrayList();

while (inFile.hasNext()) { String [] tokens = null; s = inFile.nextLine(); String[] triplet = s.split("[\\|]"); //this will always overwrite tokens //And triplet has 4 positions (0,1,2,3) so you cant just have int u,v and w /* for (String i : triplet){ tokens = i.split("[,]"); } */

int u = Integer.parseInt(tokens[0].trim()); int v = Integer.parseInt(tokens[1].trim()); int w = Integer.parseInt(tokens[2].trim());

} } }

class GraphView extends JPanel { private int position; private int edge; //construct a graphview object public GraphView() { } //construct a graphview object with specified position and edge public GraphView(int position, int edge) { } protected void paintComponent(Graphics g) { super.paintComponent(g); Scanner scan = new Scanner(new File("myFile.txt")); // scanner to read file String line = scan.nextLine(); // read first line int nbLine = Integer.parseInt(line); // get number of lines ArrayList al = new ArrayList

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!