Answered You can hire a professional tutor to get the answer.

QUESTION

adding the try/catch blocks. This is the WriteData.java program: public class WriteData { public static void main(String args) throws Exception {...

Please help with 4. adding the try/catch blocks.

This is the WriteData.java program:

public class WriteData {

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

   java.io.File file = new java.io.File("scores.txt");

   if (file.exists()) {

     System.out.println("File already exists");

     System.exit(0);

   }

   // Create file

   java.io.PrintWriter output = new java.io.PrintWriter(file);

   // Write formatted output to the file

   output.print("John T Smith ");

   output.println(90);

   output.print("Eric K Jones ");

   output.println(85);

   // Close the file

   output.close();

 }

}

Here is the whole question:

  • Attachment 1
  • Attachment 2
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question