Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

5. Who should facilitate the focus group?

Answered: 1 week ago