Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Specification: Start with the given Java program prog340, which lets you select a file to read from your computer, reads the file, and interprets that

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Specification: Start with the given Java program "prog340", which lets you select a file to read from your computer, reads the file, and interprets that file as the specification of a graph.' Then enhance it to do the following: 1. Write code necessary to print out, for each Edge, the name of the Node from which the Edge emanates, the name of the Node at which the Edge terminates, and the label of the Edge, in the format listed below. The "prog340" handout describes the format of the input file for this and all program deliverables. As will always be the case in this class, the program must be written in Java and must run on the University Windows computer systems. Output: Here is sample output for one graph. BB E val X 67 fig 999 -42 3 DDD 99 X y2 Alfa Bravo Charlie Delta Echo 9 3 22 yes de 33 The output for this file should be: Edge from Alpha to Bravo labeled >. Edge from Alpha to Delta labeled 99. Edge from Alpha to Echo labeled fig. Edge from Bravo to Alpha labeled 999. Edge from Bravo to Bravo labeled -42. Edge from Bravo to Charlie labeled 3. Edge from Bravo to Delta labeled x. Edge from Bravo to Echo labeled ==. Edge from Charlie to Bravo labeled 4. Edge from Charlie to Delta labeled yz. Edge from Charlie to Echo labeled 9. Edge from Delta to Alpha labeled 3. Edge from Delta to Bravo labeled 22. Edge from Delta to Charlie labeled x. Edge from Delta to Echo labeled !-2. Edge from Echo to Delta labeled de. Edge from Echo to Echo labeled 33. The order in which the Edges print out is not important. puble classro View import java.io. import java.util. Class Dildo the work for deliverable of the public clase Delta File input lle pile Printeriter output ArrayListede nodes leylistit public Graph) modelist - w ArrayList Codes); dget ArrayList Edge; public Deliv ile in Graph) inutile public ArrayListcode predalisto reti nodes > public ArrayLista de petrtist VI Get output filem string input-inputste.tostri String bowl.metrotime. itrine, inutile.xh):4). // Strip off tot String output flow.concat(cut. ) Filetel output) HotFilemista) 7 Forretests outputFile.delete) 1 try but Printerloputte) tuh (copia) System.erforation ) 1 System.out.printin evideo te implemented"); output.print Dalk to the momente") output. public voidade Neden ) modelistad) ) public void odprlige) angelistad) Nedensted Viled mat View Help mort java.util.. Ad for the Soring 2018 TOS Wieport java.util.. og between twe nodes public class Edge string label: Int dist Node tail: Rode head le code String String the value of the String the breviation for the Mode Array ArrayList Incoming ble de String the see the valls ull w ArrayListe) Inconincs new ArrayList; public de Mode tailode, ode hadde, string the label) setLabel( thebel ) setrall talde) setreadheadhode): 1 public string gettabel) return label 3 pulte Stri) Return . public Strine et return 1 public de getallo return tal 1 public tiode gestad) return head 1 Public Strine otval( return val public arrayList des groutgoing) return outings: public int getost return disti 1 public void settabel( String) Duli ArrayListEdge putinconnages return Incomingages > public void setoreve String the best were there 1 public void stall Noden 1 puitte void seta Mode) E 1 public void settleme Site 2 public void seal String the vel the public void setoist Strines) dist teger.parseInts): 1 catch beforteption afe) dist - Inter AX VALUE; public void acouting to outrages.) 1 public void winning angel Incones) ile this Sit direct, Photo Wil ---- Select the SAS Strelec . Ver Stre Stri) wtopic to use . . MESIMI listen to the et Actor ( ht . Pedro) DV - the De Derd, Dette Sy.. SON case 4: System.out.println("Goodbye"); System.exit(0); default: System.out.println("Invalid choice" ); System.exit(0); * Read the file containing the strings, line by line, the process each line as it is read. public void readGraphInfo Graph) try 14 (fileChooser.showOpenDialog(null) - FileChooser. APPROVE_OPTION) 1/ Instantiate the selected input and output files. Input File = fileChooser.getSelectedFile(); System.out.println("Chosen Fle.. inputFile) 1 1/ read text file Scanner s = new Scanner inputFile); // First line special: It contains, and "val", and the nodes with the edges. String First Line - sc.nextLine(); String[] splitString - Firstline.split(""); 1/ Tgnore first two fields of first line, Every other field is a node. for (int -2; i 1/ Every other line gives the name and value of the Mode, and any edges. int node Index - e; ArrayListcode podelist - EsetNodelist(): while shas extLine()) String nextLine - Sc.nextLine(); splitString - nextLine.split(" ") Nodennodelistet node Index > n.setName( splitString()); o.setVal spilt String 5 for (int i = 2; 1 rode Index s.close) Catch (teception ) System.err.format("Exception outer ". ABO - Notepad C N N File Edit Format View Help F val AAA BB Alfa S > Bravo 67 999 - 42 Charlie 4 Delta 4e 22 Echo yes == DDD E 99 fig yz 9 !=2 d>e 33 2 X 2 w2 N 2 m N Specification: Start with the given Java program "prog340", which lets you select a file to read from your computer, reads the file, and interprets that file as the specification of a graph.' Then enhance it to do the following: 1. Write code necessary to print out, for each Edge, the name of the Node from which the Edge emanates, the name of the Node at which the Edge terminates, and the label of the Edge, in the format listed below. The "prog340" handout describes the format of the input file for this and all program deliverables. As will always be the case in this class, the program must be written in Java and must run on the University Windows computer systems. Output: Here is sample output for one graph. BB E val X 67 fig 999 -42 3 DDD 99 X y2 Alfa Bravo Charlie Delta Echo 9 3 22 yes de 33 The output for this file should be: Edge from Alpha to Bravo labeled >. Edge from Alpha to Delta labeled 99. Edge from Alpha to Echo labeled fig. Edge from Bravo to Alpha labeled 999. Edge from Bravo to Bravo labeled -42. Edge from Bravo to Charlie labeled 3. Edge from Bravo to Delta labeled x. Edge from Bravo to Echo labeled ==. Edge from Charlie to Bravo labeled 4. Edge from Charlie to Delta labeled yz. Edge from Charlie to Echo labeled 9. Edge from Delta to Alpha labeled 3. Edge from Delta to Bravo labeled 22. Edge from Delta to Charlie labeled x. Edge from Delta to Echo labeled !-2. Edge from Echo to Delta labeled de. Edge from Echo to Echo labeled 33. The order in which the Edges print out is not important. puble classro View import java.io. import java.util. Class Dildo the work for deliverable of the public clase Delta File input lle pile Printeriter output ArrayListede nodes leylistit public Graph) modelist - w ArrayList Codes); dget ArrayList Edge; public Deliv ile in Graph) inutile public ArrayListcode predalisto reti nodes > public ArrayLista de petrtist VI Get output filem string input-inputste.tostri String bowl.metrotime. itrine, inutile.xh):4). // Strip off tot String output flow.concat(cut. ) Filetel output) HotFilemista) 7 Forretests outputFile.delete) 1 try but Printerloputte) tuh (copia) System.erforation ) 1 System.out.printin evideo te implemented"); output.print Dalk to the momente") output. public voidade Neden ) modelistad) ) public void odprlige) angelistad) Nedensted Viled mat View Help mort java.util.. Ad for the Soring 2018 TOS Wieport java.util.. og between twe nodes public class Edge string label: Int dist Node tail: Rode head le code String String the value of the String the breviation for the Mode Array ArrayList Incoming ble de String the see the valls ull w ArrayListe) Inconincs new ArrayList; public de Mode tailode, ode hadde, string the label) setLabel( thebel ) setrall talde) setreadheadhode): 1 public string gettabel) return label 3 pulte Stri) Return . public Strine et return 1 public de getallo return tal 1 public tiode gestad) return head 1 Public Strine otval( return val public arrayList des groutgoing) return outings: public int getost return disti 1 public void settabel( String) Duli ArrayListEdge putinconnages return Incomingages > public void setoreve String the best were there 1 public void stall Noden 1 puitte void seta Mode) E 1 public void settleme Site 2 public void seal String the vel the public void setoist Strines) dist teger.parseInts): 1 catch beforteption afe) dist - Inter AX VALUE; public void acouting to outrages.) 1 public void winning angel Incones) ile this Sit direct, Photo Wil ---- Select the SAS Strelec . Ver Stre Stri) wtopic to use . . MESIMI listen to the et Actor ( ht . Pedro) DV - the De Derd, Dette Sy.. SON case 4: System.out.println("Goodbye"); System.exit(0); default: System.out.println("Invalid choice" ); System.exit(0); * Read the file containing the strings, line by line, the process each line as it is read. public void readGraphInfo Graph) try 14 (fileChooser.showOpenDialog(null) - FileChooser. APPROVE_OPTION) 1/ Instantiate the selected input and output files. Input File = fileChooser.getSelectedFile(); System.out.println("Chosen Fle.. inputFile) 1 1/ read text file Scanner s = new Scanner inputFile); // First line special: It contains, and "val", and the nodes with the edges. String First Line - sc.nextLine(); String[] splitString - Firstline.split(""); 1/ Tgnore first two fields of first line, Every other field is a node. for (int -2; i 1/ Every other line gives the name and value of the Mode, and any edges. int node Index - e; ArrayListcode podelist - EsetNodelist(): while shas extLine()) String nextLine - Sc.nextLine(); splitString - nextLine.split(" ") Nodennodelistet node Index > n.setName( splitString()); o.setVal spilt String 5 for (int i = 2; 1 rode Index s.close) Catch (teception ) System.err.format("Exception outer ". ABO - Notepad C N N File Edit Format View Help F val AAA BB Alfa S > Bravo 67 999 - 42 Charlie 4 Delta 4e 22 Echo yes == DDD E 99 fig yz 9 !=2 d>e 33 2 X 2 w2 N 2 m N

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 3 Lnai 9853

Authors: Bettina Berendt ,Bjorn Bringmann ,Elisa Fromont ,Gemma Garriga ,Pauli Miettinen ,Nikolaj Tatti ,Volker Tresp

1st Edition

3319461303, 978-3319461304

More Books

Students also viewed these Databases questions

Question

What are negative messages? (Objective 1)

Answered: 1 week ago