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 in the class. Each sub sequence line will list the student's first name, followed by their four exam scores (all separated by spaces).
The overall average for each student will be calculated by averaging the three highest test scores for each student. The teacher uses the following grading scale to assign a letter grade to a student:
Write a class called GradeBook that uses the following instance variables (attributes):

Note: You may add more methods to the class if it you wish.
After implementing the GradeBook class, use the given Assgnment8.java. which has the main method to test your class. The program asks the user for the file name.
Assgnment8.java
import java.util.Scanner;
import java.io.*;
public class Assignment8
{
static Scanner in = new Scanner(System.in);
public static void main (String[] args) throws IOException
{
String command = " ";
System.out.print("Please enter the filename: ");
String fileName = in.nextLine();
GradeBook grades = new GradeBook(fileName);
while (command.charAt(0) != 'q') {
System.out.println();
System.out.print("Please enter a command or type \"?\" to see the
menu: ");
command = in.nextLine();
switch (command.charAt(0)) {
case 'a': // display all
System.out.println(grades.toString());
break;
case 'b' : // search
System.out.print("Type student name: ");
String name = in.nextLine();
int index = grades.getIndex(name);
char grade = grades.getLetterGrade(index);
if (index != -1)
System.out.println(name + " " + grade);
else
System.out.println("Student doesn't exist!");
break;
case '?' : // help menu
System.out.println("a: Display ");
System.out.println("b: Search ");
System.out.println("?: Help menu ");
System.out.println("q: Stop the program ");
break;
case 'q': // stop the program
break;
default:
System.out.println("Illegal cammand!!!");
} // end of switch
} // end of while
}// end main
} // end Assignment8
Helpful hints for doing this assignment:
• Work on it in steps – write one method, test it with a test
driver and make sure it works before going on to the next
method
• Always make sure your code compiles before you add another
method
Sample Output: with user input in red
Please enter the filename: roster.txt Please enter a command or type "?" to see the menu: a Sally 83.0 B Rachel 79.7 C Melba 91.0 A Grace 77.3 C Lisa 77.0 C Please enter a command or type "?" to see the menu: b Type student name: Melba Melba A Please enter a command or type "?" to see the menu: b Type student name: Lisa Lisa C Please enter a command or type "?" to see the menu: b Type student name: Rick Student doesn't exist! Please enter a command or type "?" to see the menu: q
Note: Do not use any Java language or library features that we have not already covered in class. For example, do not use ArrayLists.
If you have any doubts, please give me comment...
import java.util.Scanner;
import java.io.*;
public class GradeBook{
public static final int NUM_TESTS = 4;
private int numStudents;
private String[] names;
private char[] grades;
private double scores[][];
public GradeBook(String fileName) throws IOException{
Scanner fin = new Scanner(new File(fileName));
int n=0;
fin.next(); //skipping count string
numStudents = fin.nextInt();
names = new String[numStudents];
grades = new char[numStudents];
scores = new double[numStudents][NUM_TESTS];
while(fin.hasNext()){
names[n] = fin.next();
for(int i=0; i<NUM_TESTS; i++)
scores[n][i] = fin.nextDouble();
n++;
}
assignGrades();
fin.close();
}
private double getStudentAverage(int index){
double sum = 0.0;
for(int i=0; i<NUM_TESTS;i++){
sum += scores[index][i];
}
return sum/NUM_TESTS;
}
private void assignGrades(){
for(int i=0; i<numStudents; i++){
double avg = getStudentAverage(i);
if(avg>=90 && avg<=100)
grades[i] = 'A';
else if(avg>=80 && avg<90)
grades[i] = 'B';
else if(avg>=70 && avg<80)
grades[i] = 'C';
else if(avg>=60 && avg<70)
grades[i] = 'D';
else
grades[i] = 'E';
}
}
public String getStudentName(int index){
return names[index];
}
public char getLetterGrade(int index){
return grades[index];
}
public int getIndex(String studentName){
for(int i=0; i<numStudents; i++){
if(names[i].equalsIgnoreCase(studentName))
return i;
}
return -1;
}
public String toString(){
String str = "";
for(int i=0; i<numStudents; i++){
str += names[i]+"\t"+getStudentAverage(i)+"\t"+grades[i]+"\n";
}
return str;
}
}
import java.util.Scanner;
import java.io.*;
public class Assignment8 {
static Scanner in = new Scanner(System.in);
public static void main(String[] args) throws IOException {
String command = " ";
System.out.print("Please enter the filename: ");
String fileName = in.nextLine();
GradeBook grades = new GradeBook(fileName);
while (command.charAt(0) != 'q') {
System.out.println();
System.out.print("Please enter a command or type \"?\" to see the menu: ");
command = in.nextLine();
switch (command.charAt(0)) {
case 'a': // display all
System.out.println(grades.toString());
break;
case 'b': // search
System.out.print("Type student name: ");
String name = in.nextLine();
int index = grades.getIndex(name);
char grade = grades.getLetterGrade(index);
if (index != -1)
System.out.println(name + " " + grade);
else
System.out.println("Student doesn't exist!");
break;
case '?': // help menu
System.out.println("a: Display ");
System.out.println("b: Search ");
System.out.println("?: Help menu ");
System.out.println("q: Stop the program ");
break;
case 'q': // stop the program
break;
default:
System.out.println("Illegal cammand!!!");
} // end of switch
} // end of while
}// end main
} // end Assignment8
Your assignment is to write a grade book for a teacher. The teacher has a text file, which includ...
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...
Please provide the full code...the skeleton is down below: Note: Each file must contain an int at the beginning, stating the number of records in the file. Afterwards, the number of records in the file will follow. Each record that follows will consist of a last name (String), and a gpa (double). However, to test the error handling of your program, the number of records will not always match the int value. All possible combinations should be tested. 1.) Prompt...
Input hello, I need help completing my assignment for java,Use the following test data for input and fill in missing code, and please screenshot output. 1, John Adam, 3, 93, 91, 100, Letter 2, Raymond Woo, 3, 65, 68, 63, Letter 3, Rick Smith, 3, 50, 58, 53, Letter 4, Ray Bartlett, 3, 62, 64, 69, Letter 5, Mary Russell, 3, 93, 90, 98, Letter 6, Andy Wong, 3, 89,88,84, Letter 7, Jay Russell, 3, 71,73,78, Letter 8, Jimmie Wong,...
You’ll create the parser with a 2-part layered approach. You’ll first create a Lexer, which will read characters from a file and output tokens. Then you’ll write the second part, which will process the tokens and determine if there are errors in the program. This program have 3 files Lexer.java, Token.java, Parser.java Part 1 Lexer: The class Lexer should have the following methods: public constructor which takes a file name as a parameter○private getInput which reads the data from the...
CSC110
Lab 6 (ALL CODING IN JAVA)
Problem: A text file contains a paragraph. You are to read the
contents of the file, store the UNIQUEwords and count the
occurrences of each unique word. When the file is completely read,
write the words and the number of occurrences to a text file. The
output should be the words in ALPHABETICAL order along with the
number of times they occur and the number of syllables. Then write
the following statistics to...
Language Java Step 1: Design a class called Student. The Student class should contain the following data: firstName lastName studentID totalCredits gpa Your class should implement the “sets” and “gets” for the class. Include methods: equals, compareTo, toString. Change the toString method (from class) to put each member variable on a new line. Step 2: Write a driver program to test that Student works correctly. Test is with 3 students as given in class. Step 3: Write a “registration” program...
Set-Up · Create a new project in your Eclipse workspace named: Lab13 · In the src folder, create a package named: edu.ilstu · Import the following files from T:\it168\Labs\lab13. Note that the .txt file must be in the top level of your project, not inside your src folder. o Student.java o StudentList.java o students.txt Carefully examine the Student.java and StudentList.java files. You are going to complete the StudentList class (updating all necessary Javadoc comments), following the instruction in the code....
I need code in java
The Student class:
CODE IN JAVA:
Student.java file:
public class Student {
private String name;
private double gpa;
private int idNumber;
public Student() {
this.name = "";
this.gpa = 0;
this.idNumber = 0;
}
public Student(String name, double gpa, int
idNumber) {
this.name = name;
this.gpa = gpa;
this.idNumber = idNumber;
}
public Student(Student s)...
: Files and Exceptions: Write a program to create and use a grade book for a course. The gradebook is created as a file named as “Course_Name.dat” and includes the following information about students: Student ID, First Name, Last Name, and Grade. Assume the following structure for the gradebook file:1.Students’ records are separated by a new-line character.2.No field includes any white-space character, and fields are separated by space.3.The order of the fields is the same for all the records.Based on...
Hello I'm having a bit of trouble with this assignment. Any help would be appreciated! Overview You must implement a Java class which simulates a Student object. These Student objects will represent grade records for students. Variable Details name : private String : represents the Student’s name sid: private String : represents the Student’s ID number quizzes: private double[] : an array whose size is equal to NUM_QUIZZES. Each element will be used to store one of...