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

Java SPECIFICATIONS Write a class for Student grade data and write a program to

ID: 3806827 • Letter: J

Question

Java SPECIFICATIONS Write a class for Student grade data and write a program to create an object from this class and use it to produce a report Write a class for Student grade data: 1. The class will have the following fields: Student id An array of ten test grades 2. Create void “set” methods to store values in Student id and the array 3. Create a value-returning “get” method to retrieve values from the fields, one for each field 4. Create a constructor with arguments for Student id and the array (use set methods) 5. Create a noArg constructor (use set methods, consider what the default values should be) 6. Create a method to calculate the total of test grades 7. Create a method to calculate the adjusted total, dropping the lowest test score and replace it with the highest test score (highest test counts twice, drop lowest test) see Lab05Logic 8. Create a method to calculate the average of the ten test grades based upon the adjusted total and round to the nearest integer Create Lab05 9. Input data from the Lab05StudentFile.txt 10. Create an object from the Student class and use the constructor to place values into the object 11. Use the class method to calculate the total 12. Use the class method to calculate the adjusted total 13. Use the class method to calculate the average 14. Use data from the object and write the report to an output file 15. Accumulate and print the number of students . INPUT File: Student file Lab05StudentFile.txt Record: Student record Field Data Type Student id# 4 numbers (ex. 1234) Ten test scores integers (valid numbers are 0 -100) OUTPUT File: Grade Report file Lab05Report.txt Record: Student Grade Report ID# /-----------------------TEST Scores--------------------------/ Total Adj Total Avg xxxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxxx xxxx xxx xxxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxxx xxxx xxx xxxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxxx xxxx xxx Total students = xx inout 1221 100 100 100 100 100 100 100 100 100 100 1222 87 87 87 87 87 87 87 87 87 87 1223 80 80 80 80 80 80 80 80 80 80 1224 77 77 77 77 77 77 77 77 77 77 1225 70 70 70 70 70 70 70 70 70 70 1226 67 67 67 67 67 67 67 67 67 67 1227 60 60 60 60 60 60 60 60 60 60 1228 57 57 57 57 57 57 57 57 57 57 1343 90 85 80 65 75 95 85 75 80 94 1555 70 70 70 60 65 90 85 80 80 80 1856 60 0 45 68 89 67 60 50 75 80 1967 90 85 87 88 70 90 92 87 88 67 1987 68 68 68 68 68 68 68 68 68 100 1989 59 59 59 59 59 59 59 59 59 75 1991 100 90 75 85 90 88 79 88 91 90 1993 91 90 75 85 90 88 79 88 91 90

Explanation / Answer

// StudentGrade.java


public class StudentGrade {
public StudentGrade(int studentid, int[] grades) {
setStudentid(studentid);
setGrades(grades);
}
  
public StudentGrade() {
setStudentid(0);
setGrades(null);
}
  
private int studentid;
private int[] grades = new int[10];
public int getStudentid() {
return studentid;
}
public void setStudentid(int studentid) {
this.studentid = studentid;
}
public int[] getGrades() {
return grades;
}
public void setGrades(int[] grades) {
this.grades = grades;
}
  
public int totalGrades()
{
int total = 0;
for(int i = 0; i < grades.length; i++)
{
total += grades[i];
}
return total;
}
  
public int adjustedTotal()
{
int min = grades[0];
int max = grades[0];
for(int i = 1; i < grades.length; i++)
{
if (min > grades[i])
{
min = grades[i];
}
if (max < grades[i])
{
max = grades[i];
}
}
int total = totalGrades() - min + max;
return total;
}
  
public int averageGrades()
{
int total = adjustedTotal();
double avg = total/grades.length;
return (int)Math.rint(avg);
}
}

// TestStudentGrade.java

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;


public class TestStudentGrade {

public static void main(String[] args) throws IOException
{
FileReader fr = new FileReader("Lab05StudentFile.txt");
Scanner sc = new Scanner(fr);
  
FileWriter fw = new FileWriter("Lab05Report.txt");
int studentCount = 0;
while(sc.hasNextLine())
{
int id = sc.nextInt();
int[] grades = new int[10];
for(int i = 0; i < grades.length; i++)
grades[i] = sc.nextInt();
  
StudentGrade studentGrade = new StudentGrade(id, grades);
studentCount++;
fw.write(id + " ");
for(int i = 0; i < grades.length; i++)
fw.write(grades[i] + " ");
fw.write(studentGrade.totalGrades() + " ");
fw.write(studentGrade.adjustedTotal() + " ");
fw.write(studentGrade.averageGrades() + " ");
}
sc.close();
fr.close();
  
fw.write("Total students = " +studentCount + " ");
  
fw.close();
}
}

// Lab05Report.txt

1221 100 100 100 100 100 100 100 100 100 100 1000 1000 100
1222 87 87 87 87 87 87 87 87 87 87 870 870 87
1223 80 80 80 80 80 80 80 80 80 80 800 800 80
1224 77 77 77 77 77 77 77 77 77 77 770 770 77
1225 70 70 70 70 70 70 70 70 70 70 700 700 70
1226 67 67 67 67 67 67 67 67 67 67 670 670 67
1227 60 60 60 60 60 60 60 60 60 60 600 600 60
1228 57 57 57 57 57 57 57 57 57 57 570 570 57
1343 90 85 80 65 75 95 85 75 80 94 824 854 85
1555 70 70 70 60 65 90 85 80 80 80 750 780 78
1856 60 0 45 68 89 67 60 50 75 80 594 683 68
1967 90 85 87 88 70 90 92 87 88 67 844 869 86
1987 68 68 68 68 68 68 68 68 68 100 712 744 74
1989 59 59 59 59 59 59 59 59 59 75 606 622 62
1991 100 90 75 85 90 88 79 88 91 90 876 901 90
1993 91 90 75 85 90 88 79 88 91 90 867 883 88
Total students = 16

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