0.Introduction. In this assignment you are required to develop and test the following two classes:

  • Programming2Student - represents a Programming 2 student;
  • Programming2Class – represents a Programming 2 teaching class(group);.

The class diagrams for these classes are provided.

The relevant information about a Programming 2 student includes: the first name, surname, and marks for Lab Test, Assignment1, Assignment2, and Final Exam.

The ranges for each of the assessment task marks are given below, also it is explained how to calculate the final grade:

  • Lab Test Mark – is an integer from 0 to 10;
  • Assignment1 Mark – is an integer from 0 to 20;
  • Assignment2 Mark – is an integer from 0 to 20;
  • Final exam Mark – is an integer from 0 to 50;

A total mark is the sum of the previous four marks, so it is an integer from 0 to 100.

A student passes the unit if and only if (Assignment1 Mark + Assignment2 Mark) >= 20 and (Lab Test Mark + Final Exam Mark) >= 30

There are 5 grades, which are calculated according to the following rules:

  • F – if the Total Mark is less then 40;
  • MF – if (40 <= Total Mark < 50) or (Total Mark >= 50 but student didn’t pass);
  • P – if (50 <= Total Mark < 60) and student passed;
  • C – if (60 <= Total Mark < 70) and student passed;
  • D – if (70 <= Total Mark < 80) and student passed;
  • HD – if Total Mark >= 80;
  • (1) The data fields have self-explanatory identifiers, and their meanings should be clear from the Introduction.

You are required to develop your application using Java in the Eclipse environment.

Class Programming2Student

Develop class Programming2Student using the following diagram and explanations that follow the diagram. Public set and get methods for the instance variables are not included in the diagram for space considerations. However, you should provide them. See image.

(1) The data fields have self-explanatory identifiers, and their meanings should be clear from the Introduction.

(2) The first constructor creates a “default” student object – it should be you – and sets all the marks to 0. The second constructor creates a student object with specified name and surname and zero marks for all assessment tasks. The third constructor creates a student object with full name and all the marks specified.

(3) The “set” methods allow the user to set the assessment task marks within the specified margins, e.g. setExamMark must ensure that the examMark is in the range from 0 to 50.

(4) The method getGrade() returns the student’s grade, calculated as specified in the Introduction. The rest of the “get” methods simply return the values of the corresponding fields.

(5) The method passed() returns true if this student has passed the course, and returns false otherwise (see the Introduction).

(6) The method toString() returns a string representation of a Programming2Student object in the following printable format:

John Smith:
Assignment 1 8
Assignment 2 16
Lab Test 0
Exam 34
Grade P

Class Programming2Class

Develop class Programming2Class using the following diagram and explanations that follow the diagram. Public set and get methods for the instance variables are not included in the diagram for space considerations. However, you should provide them. Objects of this class represent Programming2 teaching classes (student groups). See image.

(1) There are three instance variables in the class:

  • numberOfStudents – the number of students in the class;
  • capacityOfClass – the maximal allowed number of students in the class;
  • group - an array of Programming2Student objects studying in the class; group's size is equal to the capacityOfClass.

(2) There are two constructors - a default constructor that creates an empty class with the default capacity equal to 20, and a constructor that creates an empty class with a specified capacity.

(3) addStudent(Programming2Student s) method adds a Programming2Student object to the group if the capacity of the class is greater then the number of students in the class, else it just prints that the class is full. Make sure that every time you add a student to the class the value of the numberOfStudents variable increases by one.

(4) toString() method returns the list of all students from the class in a printable string format. In the implementation you should use the Programming2Student's toString() method.

Class TestAssignment1

Write a test program to test the Programming2Student and Programming2Class classes. You should perform the following tasks in the main method of the Test class:

  • Create six Programming2Student objects, including the object representing yourself.
  • Create a Programming2Class object of capacity five. Try to add all the created students to the class. Make sure that only five first students are added.
  • “Mark” all the students from the class, i.e. assign values to the examMark, labMark etc.
  • Print the list of all the students from the the class with their marks and grades.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.