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

Java ive asked this here a couple times becuase the answers i get seem good but

ID: 3863889 • Letter: J

Question

Java

ive asked this here a couple times becuase the answers i get seem good but have errors and won't compile

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

input file

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

student class

//class constructor
   public Student(int inStudentId, int [ ] inStudentGrades)
   {//begin method
   setStudentId (inStudentId);
   setStudentGradeArray(inStudentGrades);
   }//end method


//class default constructor    public Student()
   {//begin method
   int tempArray [ ] = {0,0,0,0,0,0,0,0,0,0};
   setStudentId (0);
   setStudentGradeArray(tempArray);
   }//end method


   public void setStudentGradeArray (int [ ] inStudentGrades)
   {//begin method
   for (int c = 0; c<10; c++)
      studentGrades [c] = inStudentGrades [c];
   }//end method

Explanation / Answer

//Student.java
public class Student
{
   private int inStudentId;
   private int [] inStudentGrades=new int[10];
   //class default constructor  
   public Student()
   {      
       int tempArray [ ] = {0,0,0,0,0,0,0,0,0,0};
       setStudentId (0);
       setStudentGradeArray(tempArray);
   }//end method
  
   public void setStudentGradeArray (int[] inStudentGrades)
   {//begin method
       for (int c = 0; c<inStudentGrades.length; c++)
           this.inStudentGrades[c] = inStudentGrades [c];
   }//end method
  
  
   //Returns total
   public double getTotal()
   {
       double total=0;
       for (int i = 0; i < inStudentGrades.length; i++)
       {
           total+=inStudentGrades[i];
       }
      
       return total;
   }
  
   //Returns adjusted total
   public double adjustedtotal()
   {
       int lowestScore=getLowestScore();
       int highestScore=getHighestScore();
       double total=getTotal();
       total=total-lowestScore;
      
       total=total+highestScore;      
       return total;      
   }
  
   //Returns the adjusted avereage
   public double getAdjustedAverage()
   {
       double total=0;
       total=adjustedtotal();      
       return total/inStudentGrades.length;
   }
  
  

   //Returns highest score
   public int getHighestScore()
   {
       int high=inStudentGrades[0];
       for (int i = 1; i < inStudentGrades.length; i++)
       {
           if(inStudentGrades[i]>high)
               high=inStudentGrades[i];
       }
       return high;
   }
  
   //Returns lowest score
   public int getLowestScore()
   {
       int low=inStudentGrades[0];
       for (int i = 1; i < inStudentGrades.length; i++)
       {
           if(inStudentGrades[i]<low)
               low=inStudentGrades[i];
       }
       return low;
   }

   //class constructor
   public Student(int inStudentId, int [] inStudentGrades)
   {      
       setStudentId (inStudentId);
       setStudentGradeArray(inStudentGrades);
   }//end method


   public void setStudentId(int inStudentId)
   {
       this.inStudentId=inStudentId;  
   }

  

}//end of Student

--------------------------------------------------------------------------------------

/**
* The java test program StudentTester that creats
* a test report that contains the id ,scores
* ,total, adjusted total and adjusted average.
* */
//StudentTester.java
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class StudentTester
{
   public static void main(String[] args)
   {
       //declare a variable of type Scanner
       Scanner filescanner=null;
       //declare a variable of type PrintWriter
       PrintWriter printwriter=null;
       //declare two strings
       String infileName="Lab05Report.txt";
       String outfileName="Lab05Output.txt";
       int stdId;
       int[] scores=new int[10];

       Student std=null;
       try
       {
          
           //create an instance of filescanner object
           filescanner=new Scanner(new File(infileName));

           //create an instance of printwriter object
           printwriter=new PrintWriter(new File(outfileName));
          
           printwriter.println("Student Grade Report");
           printwriter.println();
          
           //read score until end of file
           while(filescanner.hasNextLine())
           {
               stdId=filescanner.nextInt();

               for (int i = 0; i < scores.length; i++)
               {
                   scores[i]=filescanner.nextInt();
               }
              
               std=new Student(stdId, scores);
              
               printwriter.printf("%-5d", stdId);
               for (int i = 0; i < scores.length; i++)
               {
                   printwriter.printf("%-5d", scores[i]);  
               }
              
               //write total, ajdusted total and adjusted average
               printwriter.printf("%-8.2f%-8.2f%-8.2f",
                       std.getTotal(),
                       std.adjustedtotal(),
                       std.getAdjustedAverage());          
              
               printwriter.println();
           }

          
           //close file reader and writer object streams
           filescanner.close();
           printwriter.close();

       }
       catch (IOException e)
       {              
           e.printStackTrace();
       }
   }
}

--------------------------------------------------------------------------------------

Input file :Lab05Report.txt

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

--------------------------------------------------------------------------------------

Sample output:Lab05Output.txt

Student Grade Report

1221 100 100 100 100 100 100 100 100 100 100 1000.00 1000.00 100.00
1222 87   87   87   87   87   87   87   87   87   87   870.00 870.00 87.00
1223 80   80   80   80   80   80   80   80   80   80   800.00 800.00 80.00
1224 77   77   77   77   77   77   77   77   77   77   770.00 770.00 77.00
1225 70   70   70   70   70   70   70   70   70   70   700.00 700.00 70.00
1226 67   67   67   67   67   67   67   67   67   67   670.00 670.00 67.00
1227 60   60   60   60   60   60   60   60   60   60   600.00 600.00 60.00
1228 57   57   57   57   57   57   57   57   57   57   570.00 570.00 57.00
1343 90   85   80   65   75   95   85   75   80   94   824.00 854.00 85.40
1555 70   70   70   60   65   90   85   80   80   80   750.00 780.00 78.00
1856 60   0    45   68   89   67   60   50   75   80   594.00 683.00 68.30
1967 90   85   87   88   70   90   92   87   88   67   844.00 869.00 86.90
1987 68   68   68   68   68   68   68   68   68   100 712.00 744.00 74.40
1989 59   59   59   59   59   59   59   59   59   75   606.00 622.00 62.20
1991 100 90   75   85   90   88   79   88   91   90   876.00 901.00 90.10
1993 91   90   75   85   90   88   79   88   91   90   867.00 883.00 88.30

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