Got a test coming up and I need some help understanding arrays....Below is the code I wrote to match the question which follows underneath that...
class Student{
String id;//this student's ID
int midScore;//this student's midterm score
int finalScore;//this student's final score
public Student(String id){
this.id = id;
}
public void setMidScore(int midScore){
this.midScore = midScore;
}
public void setFinalScore(int finalScore){
this.finalScore = finalScore;
}
public String getID(){
return id;
}
public int getMidScore(){
return midScore;
}
public int getFinalScore(){
return finalScore;
}
public String getInfo(){
return "ID: " + id + ", midterm: "+midScore + ", final: "+finalScore;
}
}
**HERE IS THE QUESTION....can anyone give me any pointers on how to go about this??
class StudentArray{
public static void main(String[] args){
//Part1
/*
1) Create an array of Student objects for the following students:
student 1 - ID: 9901, midterm score: 80, final score: 65
student 2 - ID: 9940, midterm score : 55, final score: 89
student 3 - ID: 9938, midterm score : 72, final score: 66
2) Display information of each students (I attempted this below)
3) Change second student's final score to 90.
4) Compute average of midterm scores
*/
Student [] array= new Student [3];
array[0]= new Student("9901");
array[1]= new Student("9940");
array[2]=new Student ("9938");
array[0].setMidScore(80);
array[0].setFinalScore(65);
array[1].setMidScore(55);
//Part2
Student[] st = new Student[100];
//All 100 Student objects are created in the following
for (int i=0; i<st.length; i++){
int studentID = 1000+i;
st[i] = new Student(studentID+"");
st[i].setMidScore((int)(Math.random()*101));
st[i].setFinalScore((int)(Math.random()*101));
}
/*Compute the following
1) midterm average,
2) final average,
3) the student's ID that has the highest score in midterm + final
4) the number of students who passed (average score in midterm and final is at least 60.0
*/
}
}