Question: Use the StudentMark class given in this assignment, override the equals method to identify the equality of both StudentMark objects in term of id and

Use the StudentMark class given in this assignment, override the equals method to identify the equality of both StudentMark objects in term of id and mark.

Write a class called Module to store a set of StudentMark objects (you can assume no more than 10 students). All objects should store in a one-dimensional array. Here is the class diagram of Module class:

Module - studentMarkList: StudentMark[] count: int Module() addStudentMark(StudentMark):void printMarkList():void getAverageMark(): double +

Implement all the methods stated inside the Module class.

Default constructor: Initialise the array object

addStudentMark method: Add new student mark into the array list

printMarkList method: Print out the student id and mark in tabular format

getAverageMark method: Calculate and return the average mark

Write the driver/test class with the main method to allow input of student ids and marks. The id XXX should denote the end of the input. The main method should also print the list of ids and marks and the overall average mark on the screen using instance methods.

public class StudentMark {
private String id;
private int mark;

public StudentMark() {
this("",0);
}

public StudentMark(String id, int mark) {
this.id = id;
this.mark = mark;
}

public String getId() {return id;}
public int getMark() {return mark;}
public void setId(String id) {this.id = id;}
public void setMark(int mark) {
if (mark>=0)
this.mark = mark;        
}

public String toString() {
return "[ID="+id + ", Mark=" + mark + "]";
}

//TASK: You have to override the equals method at here
}


Module - studentMarkList: StudentMark[] count: int Module() addStudentMark(StudentMark):void printMarkList():void getAverageMark(): double + + + +

Step by Step Solution

3.44 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

StudentMarkjava public class StudentMark private String id private int mark public StudentMar... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!