Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Could you help me to edit this problem please I only got output of Heros Name: a

ID: 3588354 • Letter: C

Question

Could you help me to edit this problem please

I only got output of

Heros Name: and Books:

this line executes the output:

System.out.println(" Hero Name : " + hero + " Books : " + bookCount);

Here is my code:

package NewP;

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.IOException;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

public class Main {

public static void main(String[] args) {

String csvFile1 = "edges.csv";

String csvFile2 = "hero-network.csv";

String csvFile3 = "nodes.csv";

BufferedReader br = null;

String line = "";

String cvsSplitBy = ",";

int heroCount = 0;

int comicCount = 0;

List<String> heroList = new ArrayList<String>();

List<String> comicList = new ArrayList<String>();

Map<String, String> typeMap = new HashMap<String, String>();

try {

// read comics or characters from the nodes.csv and count them

br = new BufferedReader(new FileReader(csvFile3));

br.readLine();

while ((line = br.readLine()) != null) {

// use comma as separator

String[] arrFile3Line = line.split(cvsSplitBy);

if (arrFile3Line[1].equalsIgnoreCase("comic")) {

comicCount++;

}

if (arrFile3Line[1].equalsIgnoreCase("hero")) {

heroList.add(arrFile3Line[0]);

heroCount++;

}

}

System.out.println("no of heros : " + heroCount);

System.out.println("no of comics : " + comicCount);

// count the number of comics for each hero from edges.csv file

System.out.println("---Mean books per character---");

for (String hero : heroList) {

br = new BufferedReader(new FileReader(csvFile1));

br.readLine();

int bookCount = 0;

while ((line = br.readLine()) != null) {

// use comma as separator

String[] arrFile1Line = line.split(cvsSplitBy);

if (hero.equalsIgnoreCase(arrFile1Line[0]))

bookCount++;

}

System.out.println(" Hero Name : " + hero + " Books : " + bookCount);

}

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

} finally {

if (br != null) {

try {

br.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

}

for more explanation:

• nodes.csv – Contains two columns, node and type. Each row defines a node in the social

network. Node is the name of the node and type is either hero or comic.

• edges.csv – Contains two columns, hero and comic. Each row defines an edge from a hero node

to a comic node in the social network.

• hero-network.csv – Contains two columns, hero1 and hero2. Each row defines an instance of

two heroes appearing in a single comic.

(coma separates the hero and comic in edges.csv and inside the edges.csv file contains hero and comic)

edges.csv

hero,comic

24-HOUR MAN/EMMANUEL,AA2 35

3-D MAN/CHARLES CHAN,AVF 4

3-D MAN/CHARLES CHAN,AVF 5

3-D MAN/CHARLES CHAN,COC 1

3-D MAN/CHARLES CHAN,H2 251

3-D MAN/CHARLES CHAN,H2 252

3-D MAN/CHARLES CHAN,M/PRM 35

3-D MAN/CHARLES CHAN,M/PRM 36

3-D MAN/CHARLES CHAN,M/PRM 37

3-D MAN/CHARLES CHAN,WI? 9

4-D MAN/MERCURIO,CA3 36

4-D MAN/MERCURIO,CM 51

4-D MAN/MERCURIO,Q 14

4-D MAN/MERCURIO,Q 16

4-D MAN/MERCURIO,T 208

4-D MAN/MERCURIO,T 214

4-D MAN/MERCURIO,T 215

4-D MAN/MERCURIO,T 216

4-D MAN/MERCURIO,T 440

8-BALL/,SLEEP 1

8-BALL/,SLEEP 19

8-BALL/,SLEEP 2

Note: (here coma separates the hero1 and hero2 inside the hero-network.csv file contains hero1 and hero2)

hero-network.csv

hero1,hero2

"LITTLE, ABNER","PRINCESS ZANDA"

"LITTLE, ABNER","BLACK PANTHER/T'CHAL"

"BLACK PANTHER/T'CHAL","PRINCESS ZANDA"

"LITTLE, ABNER","PRINCESS ZANDA"

"LITTLE, ABNER","BLACK PANTHER/T'CHAL"

"BLACK PANTHER/T'CHAL","PRINCESS ZANDA"

"STEELE, SIMON/WOLFGA","FORTUNE, DOMINIC"

"STEELE, SIMON/WOLFGA","ERWIN, CLYTEMNESTRA"

"STEELE, SIMON/WOLFGA","IRON MAN/TONY STARK "

"STEELE, SIMON/WOLFGA","IRON MAN IV/JAMES R."

"STEELE, SIMON/WOLFGA","RAVEN, SABBATH II/EL"

"RAVEN, SABBATH II/EL","FORTUNE, DOMINIC"

"RAVEN, SABBATH II/EL","ERWIN, CLYTEMNESTRA"

"RAVEN, SABBATH II/EL","IRON MAN/TONY STARK "

"RAVEN, SABBATH II/EL","IRON MAN IV/JAMES R."

"IRON MAN IV/JAMES R.","FORTUNE, DOMINIC"

"IRON MAN IV/JAMES R.","ERWIN, CLYTEMNESTRA"

"IRON MAN IV/JAMES R.","IRON MAN/TONY STARK "

"IRON MAN/TONY STARK ","FORTUNE, DOMINIC"

"IRON MAN/TONY STARK ","ERWIN, CLYTEMNESTRA"

Note: (here coma separates the node and type, and inside the nodes.csv file contains node and type)

nodes.csv

node,type

2001 10,comic

2001 8,comic

2001 9,comic

24-HOUR MAN/EMMANUEL,hero

3-D MAN/CHARLES CHAN,hero

4-D MAN/MERCURIO,hero

8-BALL/,hero

A '00,comic

A '01,comic

A 100,comic

A 101,comic

Explanation / Answer

package nithya;
import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.IOException;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;


public class nit {
public static void main(String[] args) {

  String csvFile1 = "C://Users/RNS-2/Desktop/edges.csv";

  String csvFile2 = "C://Users/RNS-2/Desktop/hero-network.csv";

  String csvFile3 = "C://Users/RNS-2/Desktop/nodes.csv";

  BufferedReader br = null;

  String line = "";

  String cvsSplitBy = ",";

  int heroCount = 0;

  int comicCount = 0;

  List<String> heroList = new ArrayList<String>();

  List<String> comicList = new ArrayList<String>();

  Map<String, String> typeMap = new HashMap<String, String>();

  try {

  // read comics or characters from the nodes.csv and count them

  br = new BufferedReader(new FileReader(csvFile3));

  br.readLine();

  while ((line = br.readLine()) != null) {

  // use comma as separator

  String[] arrFile3Line = line.split(",");
  
  for ( int i=0; i<arrFile3Line.length; i++){
   if (arrFile3Line[i].equalsIgnoreCase("comic")) {
    
    

   comicCount++;

   }
   if (arrFile3Line[i].equalsIgnoreCase("hero")) {

    heroList.add(arrFile3Line[i]);
    
    
    heroCount++;

    }
   
   
  }
  


  /*if (arrFile3Line[0].equalsIgnoreCase("comic")) {
   System.out.println("hello");

  comicCount++;

  }*/

  

  }

  System.out.println("no of heros : " + heroCount);

  System.out.println("no of comics : " + comicCount);

  // count the number of comics for each hero from edges.csv file

  System.out.println("---Mean books per character---");

  for ( String hero:heroList)
  
  {

  br = new BufferedReader(new FileReader(csvFile1));

  br.readLine();

  int bookCount = 0;

  while ((line = br.readLine()) != null) {

  // use comma as separator

  String[] arrFile1Line = line.split(",");
  
  
  if (hero.equalsIgnoreCase(arrFile1Line[0]))

  bookCount++;
  

  }
  

  System.out.println(" Hero Name : " + hero + " Books : " + bookCount);

  }
  
  } catch (FileNotFoundException e) {

  e.printStackTrace();

  } catch (IOException e) {

  e.printStackTrace();

  } finally {

  if (br != null) {

  try {

  br.close();

  } catch (IOException e) {

  e.printStackTrace();

  }

  }

  }

  }

  

}