Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

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

Step: 1

StudentMarkjava public class StudentMark private String id private int mark public StudentMar... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managerial Accounting A Focus on Ethical Decision Making

Authors: Steve Jackson, Roby Sawyers, Greg Jenkins

5th edition

324663854, 978-0324663853

More Books

Students also viewed these Programming questions