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

• SoftballPlayersPart3.java Requirements and Design: The SoftballPlayersPart3 cl

ID: 3695832 • Letter: #

Question

• SoftballPlayersPart3.java Requirements and Design: The SoftballPlayersPart3 class has only a main method as described below. In addition to the specifications in Project 10, the main method should be modified to catch and handle an IOException if one is thrown in the readPlayerFile method. o As before, main reads in the file name as the first argument, args[0], of the command line arguments, creates an instance of SoftballTeam, and then calls the readPlayerFile method in the SoftballTeam class to read in the data file and generate the five reports as shown in the output examples beginning on the next page. The main method should not include the throws IOException in the declaration. Instead, the main method should include a try-catch statement to catch IOException when/if it is thrown in the readPlayerFile method in the SoftballPlayer class. This exception is most likely to occur when an incorrect file name is passed to the readPlayerFile method. After this exception is caught and the appropriate message is printed in main, your program should end.

Explanation / Answer

package cheggprograms;

import java.io.BufferedReader;
import java.io.FileReader;
public class SoftballPlayersPart3 {
public static void main(String args[])
{
try
{
System.out.println("File name "+args[0]);
BufferedReader br=new BufferedReader(new FileReader(args[0]));
SoftballTeam sbt=new SoftballTeam();
sbt.readPlayerFile(br);
}
catch(Exception e)
{
System.out.println("Execption "+e);
}
}
}
class SoftballTeam
{
public void readPlayerFile(BufferedReader br)
{
try{
StringBuilder sb=new StringBuilder();
String line=br.readLine();
while(line!=null)
{
sb.append(line);
sb.append(" ");
line=br.readLine();
}
System.out.println(sb.toString());
}
catch(Exception e)
{
System.out.println("Execption "+e);
}
}
}