IN JAVA Description A teacher has five students who have taken four tests. The teacher uses the following grading scale to assign a letter grade to a student, based on the average of his or her four test scores. Test Score Letter Grade 90-100 A 80-89 B 70-79 C 60-69 D 0-59 F The student and score data are stored in the given file StudentInfo.txt. Create a class named GradeBook in a file named GradeBook.java. The class GradeBook is required to use a String array to hold the five students’ names, an array of five characters to hold the five students’ letter grades, and five arrays of four doubles each to hold each student’s set of test scores. The class should have methods that return a specific student’s name, average test score, and a letter grade based on the average. The program that demonstrates the class GradeBook is given in the file GradeBookDemo.java. You are required to read and understand the given program, and make the program complete and work properly with the class GradeBook. The sample output of the program is given in the file SampleOutput.txt. The sample output of the program is given in the file SampleOutput.txt. GradeBookDemo Below import java.util.Scanner; import java.io.*; /** * GradeBookDemo program * This program tests the GradeBook class by * using the data stored in the StudentInfo.txt * file. */ public class GradeBookDemo { public static void main(String[] args) throws IOException { // Create a GradeBook object. GradeBook gb = new GradeBook(); // Read the data from the file and put the data into grade book gb readFromFile(gb); // Display the student data. for (int i = 1; i <= 5; i++) { System.out.println("Name : " + gb.getName(i) + "\tAverage score: " + gb.getAverage(i) + "\tGrade: " + gb.getLetterGrade(i)); } } /** * readFromFile method */ public static void readFromFile(GradeBook gb) throws IOException { // Create the necessary objects for file input. File file = new File(".\\src\\StudentInfo.txt"); Scanner inFile = new Scanner(file); for(int student=1; student<=5; student++) { String input = inFile.nextLine(); gb.setName(student, input); double[] scores = new double[4]; for(int i=0; i<4; i++) { input = inFile.nextLine(); scores[i] = Double.parseDouble(input); } gb.setScores(student, scores); } // Close the file. inFile.close(); } } Student Info is below Joanne Smith 98 89 100 76 Will Jones 67 89 91 88 Kerry McDonald 78 79 88 91 Sam Young 88 98 76 56 Jill Barnes 94 93 91 98 Sample Output is below Name : Joanne Smith Average score: 90.75 Grade: A Name : Will Jones Average score: 83.75 Grade: B Name : Kerry McDonald Average score: 84.0 Grade: B Name : Sam Young Average score: 79.5 Grade: C Name : Jill Barnes Average score: 94.0 Grade: A This is what I have for GradeBook so far public class GradeBook { private String[] names = new String[5]; private char[] grades = new char[5]; private double[] scores1 = new double[4]; private double[] scores2 = new double[4]; private double[] scores3 = new double[4]; private double[] scores4 = new double[4]; private double[] scores5 = new double[4]; public String getName(int studentNumber) { #finish code here return student name } public double getAverage(int studentNumber) { # finish return average; } public returnLetterGrade(int studentNumber) { #finish return; } public void setName(int studentNumber, String name) { #finish } public void setScores(int studentNumber, double[] scores) { #finish

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

IN JAVA

  1. Description

A teacher has five students who have taken four tests. The teacher uses the following grading scale to assign a letter grade to a student, based on the average of his or her four test scores.

Test Score

Letter Grade

90-100

A

80-89

B

70-79

C

60-69

D

0-59

F

The student and score data are stored in the given file StudentInfo.txt. Create a class named GradeBook in a file named GradeBook.java. The class GradeBook is required to use a String array to hold the five students’ names, an array of five characters to hold the five students’ letter grades, and five arrays of four doubles each to hold each student’s set of test scores. The class should have methods that return a specific student’s name, average test score, and a letter grade based on the average.

The program that demonstrates the class GradeBook is given in the file GradeBookDemo.java. You are required to read and understand the given program, and make the program complete and work properly with the class GradeBook. The sample output of the program is given in the file SampleOutput.txt.

The sample output of the program is given in the file SampleOutput.txt.

GradeBookDemo Below

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

/**
* GradeBookDemo program
* This program tests the GradeBook class by
* using the data stored in the StudentInfo.txt
* file.
*/

public class GradeBookDemo
{
   public static void main(String[] args)
   throws IOException
   {
       // Create a GradeBook object.
       GradeBook gb = new GradeBook();

       // Read the data from the file and put the data into grade book gb
       readFromFile(gb);
      
       // Display the student data.
       for (int i = 1; i <= 5; i++)
       {
           System.out.println("Name : " + gb.getName(i) +
           "\tAverage score: " +
                                   gb.getAverage(i) +
                                   "\tGrade: " +
                                   gb.getLetterGrade(i));
       }
   }


   /**
   * readFromFile method
   */
  
   public static void readFromFile(GradeBook gb)
   throws IOException
   {
       // Create the necessary objects for file input.
       File file = new File(".\\src\\StudentInfo.txt");
       Scanner inFile = new Scanner(file);
      

       for(int student=1; student<=5; student++) {
           String input = inFile.nextLine();
           gb.setName(student, input);
           double[] scores = new double[4];
           for(int i=0; i<4; i++) {
               input = inFile.nextLine();
               scores[i] = Double.parseDouble(input);
              
           }
           gb.setScores(student, scores);
       }
         
   // Close the file.
       inFile.close();
   }
}

Student Info is below

Joanne Smith
98
89
100
76
Will Jones
67
89
91
88
Kerry McDonald
78
79
88
91
Sam Young
88
98
76
56
Jill Barnes
94
93
91
98

Sample Output is below

Name : Joanne Smith Average score: 90.75 Grade: A
Name : Will Jones Average score: 83.75 Grade: B
Name : Kerry McDonald Average score: 84.0 Grade: B
Name : Sam Young Average score: 79.5 Grade: C
Name : Jill Barnes Average score: 94.0 Grade: A

 

This is what I have for GradeBook so far

 

public class GradeBook {

       private String[] names = new String[5];
       private char[] grades = new char[5];
      
       private double[] scores1 = new double[4];
       private double[] scores2 = new double[4];
       private double[] scores3 = new double[4];
       private double[] scores4 = new double[4];
       private double[] scores5 = new double[4];
      
       public String getName(int studentNumber) {
           #finish code here return student name
       }
       public double getAverage(int studentNumber) {
           # finish return average;

       }
       public returnLetterGrade(int studentNumber) {
           #finish return;
          
       }
       public void setName(int studentNumber, String name) {
           #finish
       }
       public void setScores(int studentNumber, double[] scores) {
           #finish
       }
}
}

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,