Question

A continuation of your grading software will be made (you do not need your other code...

A continuation of your grading software will be made (you do not need your other code for this assignment). In this one you will intake a students first name and last name from a file called "students.txt". Next, there is a file called grades.txt that contains the grades in a course. There will be three grades for each student in "grades.txt" (see example file bellow). In "student.txt" there are two students first and last names. In "grades.txt" the grades for each student will be on the same line number as the students name was on in "students.txt". So if line 1 of "students.txt" contains: Joe Blow then line 1 of "grades.txt" would contain Joe Blow's grades: 85 54.3 56 Into an output file called "report.txt" output the student's last name then a comma the their first name. Following this, calculate their average and assign a letter grade using the following scale:

'A': grade >= 90 'B': 90 > grade >= 80 'C': 80 > grade >= 70 'D': 70 > grade >= 60 'F': grade < 60 If the final grade of a student is greater than 100 instead of printing their letter grade output the statement "Teacher was far too easy". The "report.txt" should have a heading on each of the columns the first saying "Student's Name" and the second saying "Student's Grade".

0 0
Add a comment Improve this question Transcribed image text
Answer #1

package StudentGrade;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

public class Grader {

   public static String getGrade(double average)
   {
       if(average > 100)
           return "Teacher was far too easy";
       else if(average >= 90)
           return "A";
       else if(average >= 80 && average < 90)
           return "B";
       else if(average >= 70 && average < 80)
           return "C";
       else if(average >= 60 & average < 70)
           return "D";
       else
           return "F";
   }
   public static void main(String[] args) {
       BufferedReader student_reader, grade_reader;
       ArrayList<String []> name_list = new ArrayList<String[]>();
       ArrayList<Double> grade_list = new ArrayList<Double>();
       int total_students = 0;
       try {
           student_reader = new BufferedReader(new FileReader("students.txt"));
           grade_reader = new BufferedReader(new FileReader("grades.txt"));
           String s_line = student_reader.readLine();
           String g_line = grade_reader.readLine();
           while (s_line != null) {
               System.out.println(s_line);
               String [] name = s_line.split(" ");
               name_list.add(name);              
               s_line = student_reader.readLine();
               System.out.println(g_line);
               String [] grades = g_line.split(" ");
               double[] grade_vals = new double[3];
               double sum = 0;
               for(int i=0;i<grades.length;i++)
               {
                   grade_vals[i]= Double.parseDouble(grades[i]);
                   sum += grade_vals[i];
               }
               grade_list.add(sum/3);
               g_line = grade_reader.readLine();
           }
           student_reader.close();
           grade_reader.close();
           total_students = name_list.size();
           BufferedWriter writer = new BufferedWriter(new FileWriter("report.txt"));
           writer.write("Student's Name\tStudent's Grade\n");
           for(int i =0;i<total_students;i++)
           {
               String last_name = name_list.get(i)[1];
               String first_name = name_list.get(i)[0];
               double avg = grade_list.get(i);
               writer.write(last_name+","+first_name+"\t"+getGrade(avg)+"\n");
           }
           writer.close();
       } catch (IOException e) {
           e.printStackTrace();
       }
   }
}

Add a comment
Know the answer?
Add Answer to:
A continuation of your grading software will be made (you do not need your other code...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Language A continuation of your grading software will be made you do not need your...

    C++ Language A continuation of your grading software will be made you do not need your other code for this assignment). In this one you will intake a students first name and last name from a file called "students.txt". Next, there is a file called grades.txt that contains the grades in a course. There will be three grades for each student in "grades.txt" (see example file bellow). In "student.txt" there are two students first and last names. In "grades.txt" the...

  • First, create two inputs that can be stored in variables consisting of a student's name. When...

    First, create two inputs that can be stored in variables consisting of a student's name. When the program begins ask "Who is the first student?" followed by "Who is the second student?" You only have to have two students for this program. Ask the user for the scores for the last three test grades for each of the students .   After the user has entered both names, and three scores for each, the program should display the following as output:...

  • In C Langage Write a grading program for a class with the following grading policies:- a. There are two quizzes, each gr...

    In C Langage Write a grading program for a class with the following grading policies:- a. There are two quizzes, each graded on the basis of 10 points. b. There is one midterm exam and one final exam, each graded on the basis of 100 points. c. The final exam counts for 50 percent of the grade, the midterm counts for 25 percent and the two quizzes together count for a total of 25 percent. Grading system is as follows:-...

  • Java Gradebook

    Requirements:1.     The number of students to enter will be dynamic, minimum of 5.2.     Ask the user for a student's:a.     first nameb.     last namec.      student IDd.     4 exam grades (each out of 100 points)Calculate the student's:e.     final letter grade.3.     For each student, if the user enters invalid data he will be allowed to enter it again.4.     Letter grade calculation will use the standard grading scale.a.     90% - 100% = Ab.     80% - 89% = Bc.      70% - 79% = Cd.     60% - 69% = De.     Below 60% = F5.     The output will consist of:a.     A list of...

  • Write a Java program that reads a file until the end of the file is encountered....

    Write a Java program that reads a file until the end of the file is encountered. The file consists of an unknown number of students' last names and their corresponding test scores. The scores should be integer values and be within the range of 0 to 100. The first line of the file is the number of tests taken by each student. You may assume the data on the file is valid. The program should display the student's name, average...

  • You must assume that the data file and your four function subprograms are located inside the working directory (forder). Please write the main program and each of the four function subprograms. 1. Th...

    You must assume that the data file and your four function subprograms are located inside the working directory (forder). Please write the main program and each of the four function subprograms. 1. The data in the following table are to be read from the file "grades.txt"and processed The grades are in percentages. The format of the data is shown below First Name ID Number Last Name Grades 001AA Tam 78.50 oe 86.45 001AB Gabriel Stuart Thus, there are 4 columns...

  • USE C++ FOR THE CODE THAT CAN RUN IN VISUAL STUDIO 2019 (or a complier) Ignore...

    USE C++ FOR THE CODE THAT CAN RUN IN VISUAL STUDIO 2019 (or a complier) Ignore the last paragraph on the bottom of the page! \ Write a program YourName-Assignments (replace Your Name with your actual name, no spaces) that reads from students' records (one student per line) in the following format: Last Name Tests Grade Assignments Grade and computes and outputs (to the console) the STUDENT STATISTICS in a table format one line per student: Student Name Total Points...

  • Your assignment is to write a grade book for a teacher. The teacher has a text file, which includ...

    Your assignment is to write a grade book for a teacher. The teacher has a text file, which includes student's names, and students test grades. There are four test scores for each student. Here is an example of such a file: Count: 5 Sally 78.0 84.0 79.0 86.0 Rachel 68.0 76.0 87.0 76.0 Melba 87.0 78.0 98.0 88.0 Grace 76.0 67.0 89.0 0.0 Lisa 68.0 76.0 65.0 87.0 The first line of the file will indicate the number of students...

  • C++ program that reads students' names followed by their test scores (5 scores) from the given...

    C++ program that reads students' names followed by their test scores (5 scores) from the given input file, students.txt. The program should output to a file, output.txt, each student's first name, last name, followed by the test scores and the relevant grade. All data should be separated by a single space. Student data should be stored in a struct variable of type StudentType, which has four components: studentFName and studentLName of type string, an array of testScores of type int...

  • Create a Student grading system. You should use a person base class (stores the name of...

    Create a Student grading system. You should use a person base class (stores the name of the student). Derive a student class from the person class. The student class stores the student ID. The student class should also store the students 3 exams (Test 1, Test 2, and Test 3) and calculate a final grade (assume the 3 tests count equally). Create an array of students for a class size of 15 students. You can use the keyboard to read...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT