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

This is a Beginner Course_Introduction to JAVA Write a complete program in Java

ID: 3863548 • Letter: T

Question

This is a Beginner Course_Introduction to JAVA

Write a complete program in Java to get data from file name DATA.TXT one line at a time until there is no more data in that file. The following is one sample line in DATA.TXT ( have as many record as you wish in DATA.TXT)

Name SSN quiz mid assignments participation final

LISA 111-11-1111 100 100 100 100 100

Jack 222-22-2222 80      80      100             90    100

Note that the first line is no in DATA.txt. Your program should create a file name RESULT.txt that reports Name, SSN and a letter grade according to the following rules: Total= 15% quiz + 15 %mid +40% assignments + 10% Participation+ 20%final If total >= 90 then A else if total>=80 then B…. You can print same output to screen as well as RESULT.txt.

This is a Beginner Course_Introduction to JAVA

Do NOT use advanced high level syntax.

Do NOT use advanced libraries beyond a beginner level.

Explanation / Answer

CourseTest.java

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;


public class CourseTest {

   public static void main(String[] args) throws FileNotFoundException {
       File file = new File("D:\DATA.txt");
       Scanner scan = new Scanner(file);
       File output = new File("D:\RESULT.txt");
       PrintWriter pw = new PrintWriter(output);
       int scoreSum = 0;
       char grade = '';
       while(scan.hasNextLine()){
           scoreSum = 0;
           String name = scan.next();
           String ssn = scan.next();
           for(int i=0; i<5; i++){
               scoreSum = scoreSum + scan.nextInt();
           }
           double average = scoreSum/(double)5;
           if(average >= 90){
               grade = 'A';
           }
           else if(average >=80 && average < 90){
               grade = 'B';
           }
           else if(average >=70 && average < 80){
               grade = 'C';
           }
           else if(average >=60 && average < 70){
               grade = 'D';
           }
           else{
               grade = 'E';
           }
           System.out.println(name+" "+ssn+" "+grade+" ");
           pw.write(name+" "+ssn+" "+grade+" ");
       }
       pw.flush();
       pw.close();
       scan.close();
   }

}

Output:

LISA   111-11-1111   A

Jack   222-22-2222   A

Result.txt

LISA   111-11-1111   A

Jack   222-22-2222   A

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