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

This is my first semester in this java class and I don\'t understand what I need

ID: 3567788 • Letter: T

Question

This is my first semester in this java class and I don't understand what I need to do to fix it. The directions state to write a Java program that reads from one file and writes to a second file. I have posted what the output is coming out as under the program. I hope someone can help.

Program:

import java.util.Scanner;
import java.io.*;

public class Grades_3_08 {

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

    Scanner input = new Scanner(System.in);
      
      // Define file names
      final String INPUT_FILE = "Grades_3_08_Input.txt";
       final String OUTPUT_FILE = "Grades_3_08_Output.txt";
    
      int grade;
      String name = " ";
      double value = 0;
      String msg = " ";
      String line = " ";
    
        
       // Access the input/output files
      File inputDataFile = new File(INPUT_FILE);
       Scanner inputFile = new Scanner(inputDataFile);
       FileWriter outputDataFile = new FileWriter(OUTPUT_FILE);
       PrintWriter outputFile = new PrintWriter(outputDataFile);
      System.out.println("Reading file " + INPUT_FILE + " " +
                           "Creating file " + OUTPUT_FILE);
                             
      // Read all of the values from the file


      while (inputFile.hasNext() ) {
      String lines=inputFile.nextLine();
      String[] words=lines.split(" ");
      grade=Integer.parseInt(words[0]);
      name=words[1];
      name = name.trim();    
      } // End while
   
      if(value >= 90)    
          {        
          msg = "OUTSTANDING";
          }
          else if (value >= 70)
          {
          msg = "Satisfactory";
          }

        
          if(value >= 90){    
               msg = "OUTSTANDING";
     }else{
     if(value >= 70){
                    msg = "Satisfactory";                                 
           
     }else
                    msg = "FAILING";
              }

          outputFile.println(value + " " + name + " " + msg);
          outputFile.println("processed names");
          outputFile.println("between 70 and 89 inclusive");
          outputFile.close();
        
       } // End outputResults
} // End class

This is the input file:

Data to use in this order:

------------------------------------

70         Light Karen L   

99         Fagan Bert Todd    

60         Antrim Forrest N   

73         Camden Warren      

80         Mulicka Al B      

99         Lee Phoebe

75         Bright Harry   

92         Garris Ted

83         Benson Martyne    

71         Lloyd Jeanine D    

43         Leslie Bennie A    

40         Brandt Leslie      

100       Schulman David     

51         Worthington Dan    

60         Hall Gus W         

60         Prigeon Dale R     

96         Fitzgibbons Rusty  

The output file comes out like this:

0.0 Fitzgibbons Rusty FAILING
processed names
between 70 and 89 inclusive

Explanation / Answer

import java.util.Scanner;
import java.io.*;

public class Grades_3_08 {

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

    Scanner input = new Scanner(System.in);
    
      // Define file names
      final String INPUT_FILE = "Grades_3_08_Input.txt";
       final String OUTPUT_FILE = "Grades_3_08_Output.txt";
  
      int grade;
      String name = " ";
      double value = 0;
      String msg = " ";
      String line = " ";
  
      
       // Access the input/output files
      File inputDataFile = new File(INPUT_FILE);
       Scanner inputFile = new Scanner(inputDataFile);
       FileWriter outputDataFile = new FileWriter(OUTPUT_FILE);
       PrintWriter outputFile = new PrintWriter(outputDataFile);
      System.out.println("Reading file " + INPUT_FILE + " " +
                           "Creating file " + OUTPUT_FILE);
                           
      // Read all of the values from the file


      while (inputFile.hasNext() ) {
      String lines=inputFile.nextLine();
      String[] words=lines.split(" ");
      grade=Integer.parseInt(words[0]);
      name=words[1];
      name = name.trim();  
     

      if(grade >= 90)  
          {      
          msg = "OUTSTANDING";
          }
          else if (grade >= 70)
          {
          msg = "Satisfactory";
          }

      
      if(grade >= 90)
      {
        msg = "OUTSTANDING";
      }
      else
      {
      if(grade >= 70)
      msg = "Satisfactory";                               
      else
      msg = "FAILING";
      }

      outputFile.println(grade + " " + name + " " + msg);
      outputFile.println("processed names");
      outputFile.println("between 70 and 89 inclusive ");
    
      
       } // End while
       outputFile.close();
}//End output
} // End class

OP:

70 Light Karen L Satisfactory
processed names
between 70 and 89 inclusive

99 Fagan Bert Todd OUTSTANDING
processed names
between 70 and 89 inclusive

60 Antrim Forrest N FAILING
processed names
between 70 and 89 inclusive

73 Camden Warren Satisfactory
processed names
between 70 and 89 inclusive

80 Mulicka Al B Satisfactory
processed names
between 70 and 89 inclusive

99 Lee Phoebe OUTSTANDING
processed names
between 70 and 89 inclusive

75 Bright Harry Satisfactory
processed names
between 70 and 89 inclusive

92 Garris Ted OUTSTANDING
processed names
between 70 and 89 inclusive

83 Benson Martyne Satisfactory
processed names
between 70 and 89 inclusive

71 Lloyd Jeanine D Satisfactory
processed names
between 70 and 89 inclusive

43 Leslie Bennie A FAILING
processed names
between 70 and 89 inclusive

40 Brandt Leslie FAILING
processed names
between 70 and 89 inclusive

100 Schulman David OUTSTANDING
processed names
between 70 and 89 inclusive

51 Worthington Dan FAILING
processed names
between 70 and 89 inclusive

60 Hall Gus W FAILING
processed names
between 70 and 89 inclusive

60 Prigeon Dale R FAILING
processed names
between 70 and 89 inclusive

96 Fitzgibbons Rusty OUTSTANDING
processed names
between 70 and 89 inclusive

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote