I'm writing a class program for a pre-wrote driver. I'm having issues accessing the array variables from the driver. I know my problem is that my setProject is trying to take my array as an argument, but the specification calls for two ints(array index, array index value). But I'm not sure how to code it as such. I've searched, but I think I'm missing something totally obvious. Just looking for some direction.

public class Student {  //Begin the Student Class

  //Declared private variables
  private String studentName;
  private String studentEmail;
  private String studentLocation;
  private int[] project; 
  private int[] quizGrades; 
  private int finalExam;
  private int participationGrade;
  private double finalGrade;
  private int sum;
  private int sum1;

  public void setStudentName (String newName){
   studentName = newName;

  public String getName(){
   return studentName;

  public void setStudentLocation (String newLocation){
   studentLocation = newLocation;

  public String getLocation(){
   return studentLocation;

  public void setStudentEmail (String newEmail){
   studentEmail = newEmail;

  public String getEmail(){
   return studentEmail;

  public double setProject(int[] newProject){
  project = newProject [4];
   int sum1 = 0;
   for (int i=0; i<=4; i++)
   sum1 = sum1 + project[i];

  public int [] getProject(){
   return project;

  public void setQuizGrades(int [] newQuizGrades){
   quizGrades = newQuizGrades[2];
   int sum = 0;
   for (int i=0; i<=2; i++)
   sum = sum + quizGrades[i];

  public int [] getQuizGrades(){
   return quizGrades;

  public void setFinalExam (int newFinalExam){
   finalExam = newFinalExam;

  public int getFinalExam(){
   return finalExam;

  public void setParticipationGrade (int newParticipationGrade){
   participationGrade = newParticipationGrade;

  public int setParticipationGrade(){
   return participationGrade;

  public void setFinalGrade(double newFinalGrade){
  finalGrade = ((sum1/10) + (sum/20) + (finalExam + participationGrade/4));

  public double setFinalGrade(){
  return finalGrade;

  public void studentReport(){
  System.out.println("Student " + studentName);
  System.out.println("Location " + studentLocation);
  System.out.println("Contact information " + studentEmail);
  System.out.println("Grade Report");
  System.out.println("Quiz 1 " + quizGrades[1]);
  System.out.println("Quiz 2 " + quizGrades[2]);
  System.out.println("Project 1 " + project[1]);
  System.out.println("Project 2 " + project[2]);
  System.out.println("Project 3 " + project[3]);
  System.out.println("Project 4 " + project[4]);
  System.out.println("Participation " + participationGrade);
  System.out.println("Final Exam " + finalExam);
  System.out.println("Final Grade: " + finalGrade);
6 Years
Discussion Span
Last Post by JamesCherrill

Looks like you should use index and value parameters to set the appropriate element of the projects array to the appropriate value, as in
projects[index] = value;


Thanks for the input... The index and value list for the array are held in a seperate driver program. I'm trying to set the method to access the index and value from that driver. But I'm unsure of how to pull the index and value from that program.

snipet of the index/values from the driver program I'm trying to access.

Public class gradeBookDriver {
 public static void main (String [] args){
  student student1 = new Student();
  student1.setProject (0,100);
  student1.setProject (1,90);
  student1.setProject (2,85);
  student1.setProject (3,95);

You don't need to pull anything. Just declare your method with the two parameters (index and value) and Java will put those values into your method when the driver calls it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.