public class Student
{   // Class variables    (applies to all students)
   static private double assignWeight = 0.25;
   static private double midtermWeight = 0.20;
   static private double examWeight = 0.55;
   static private int numOfAssignments = 5;
   
   // Instance variables    (one copy per student object)
   private int id ;
   private double midterm ;
   private double exam ;
   private boolean forCredit;
   private double[] assignments;

   // Methods
 
   //Constructors
   public Student(int theId, double theMidterm, double theExam, boolean 
                  isForCredit)
   {
      this.id = theId;
      this.midterm = theMidterm;
      this.exam = theExam;
      this.forCredit = isForCredit;
      this.assignments = new double[numOfAssignments];
   }
   
   public Student(int theId, boolean isForCredit)
   {
      this.id = theId;
      this.midterm = 0;
      this.exam = 0;
      this.forCredit = isForCredit;
      this.assignments = new double[numOfAssignments];
   }

   
   //Other methods
   public int getId()
   {
      return id;
   }
   public void setId( int id )
   {
      this.id = id;
   }
   public double getMidterm()
   {
      return midterm;
   }
   public void setMidterm( double newVal )
   {
      midterm = newVal;
   }

   public double getExam()
   {
      return exam;
   }
   public void setExam( double newMark )
   {
      exam = newMark;
   }
   public boolean getForCredit()
   {
      return forCredit;
   }
   public void setForCredit( boolean newValue )
   {
      forCredit = newValue;
   }

   public double getFinalMark()
   {
    double assignAvg = this.calculateAssignAverage( );
    double finalMark = Student.midtermWeight * this.midterm 
      + Student.examWeight * this.exam 
      + Student.assignWeight * assignAvg;
    return finalMark;
   }  
   
   private double calculateAssignAverage()
   { double avg = 0;
     for (int index = 0; index <assignments.length; index++)
     { 
       avg = avg + assignments[index];
     }
     return avg / numOfAssignments;
   }
 
   public void setAssignment(int num, double mark)
   {
     assignments[num] = mark;
   }
   
   public double getAssignment(int num)
   {
    return assignments[num];
   }
   
   public static void setExamWeight( double newWeight )
  {
     Student.examWeight = newWeight ;
  }
  public static void setMidtermWeight( double newWeight )
  {
     Student.midtermWeight = newWeight ;
  } 

  public static void setAssignmentWeight( double newWeight )
  {
     Student.assignWeight = newWeight ;
  }
      
}   
   
   
