0% found this document useful (0 votes)
52 views55 pages

Preyanka Giri

Uploaded by

giripreyanka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views55 pages

Preyanka Giri

Uploaded by

giripreyanka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Programming CS4001NI

CS4001NI Programming

30% Individual Coursework

2023-24 Autumn

Student Name: Preyanka Giri


London Met ID: 23049257
College ID: np01cp4a230427
Assignment Due Date: Friday, January 26, 2024
Assignment Submission Date: Friday, January 26, 2024

I confirm that I understand my coursework needs to be submitted online via MySecondTeacher under the
relevant module page before the deadline in order for my assignment to be accepted and marked. I am
fully aware that late submissions will be treated as non-submission and a marks of zero will be awarded.
Programming CS4001NI

Table of Contents
1. Introduction ............................................................................................. 1
2. Class Diagram ........................................................................................ 2
2.1. Class diagram of parent class (Teacher)........................................... 2
2.2. Class diagram of child class (Lecturer) ............................................. 3
2.3. Class diagram of child class(Tutor) ................................................... 4
2.4. Inherited class diagram ..................................................................... 5
3. Pseudocode ............................................................................................ 6
3.1. Pseudocode of Teacher class ........................................................... 6
3.2. Pseudocode of Lecturer class ........................................................... 8
3.3 . Pseudocode of Tutor class............................................................. 11
4. Method Description ............................................................................... 15
4.2. Method description of lecturer ......................................................... 16
4.3. Method description of Tutor ............................................................ 17
5. Test....................................................................................................... 18
5.1. Test 1.............................................................................................. 18
5.2. Test 2.............................................................................................. 22
In this test, the Tutor class was inspected, salary was set and the Tutor
class was reinspected ............................................................................ 22
5.3. Test 3.............................................................................................. 29
5.4. Test 4.............................................................................................. 31
6. Error Detection and Correction ............................................................. 34
6.1. Syntax error .................................................................................... 34
6.2. Semantic Error ................................................................................... 37
.............................................................................................................. 38
6.3. Logical Error ...................................................................................... 39
7. Conclusion ............................................................................................ 41
8. Appendix............................................................................................... 42
8.1. Teacher .......................................................................................... 42
Programming CS4001NI

8.2. Lecturer .......................................................................................... 44


8.2. Tutor ............................................................................................... 46
9. Bibliography .......................................................................................... 50
Programming CS4001NI

Fig 1 classes 1 ............................................................................................ 1

Fig 2. Class diagram of teacher 1 ............................................................... 2

Fig 3 . Class diagram of lecturer 1 .............................................................. 3

Fig 4 . Class diagram of tutor 1 ................................................................... 4

Fig 5 . Inherited class diagram 1 ................................................................. 5

Fig 6. calling constructor of lecturer 1 ....................................................... 19

Fig 7. Inspection of lecturer 1 .................................................................... 19

Fig 8. adding value to gardeassignment 1 ................................................ 20

fig 9 . reinspection of lecturer 1 ................................................................ 20

Fig .9.1.Adding value to the constructor 1 ................................................. 24

fig 10.inspection of tutor class 1 ................................................................ 25

Fig11.settingsalary and performanceindex 1............................................. 26

fig 12. reinspection of tutor class 1 ............................................................ 27

fig 13. adding result of tutor 1.................................................................... 28

fig 14 . reinspection after removal 1 .......................................................... 30


Programming CS4001NI

fig 15. details of tutor 1.............................................................................. 32

fig 16. details of lecturer 1 ......................................................................... 33

fig 17. syntax error 1 ................................................................................. 35

fig 18. correction of syntax error 1 ............................................................. 36

fig 19. semantic error 1 ............................................................................. 37

fig 20. correction of semantic error 1 ......................................................... 38

fig 21.logical error 1 .................................................................................. 39

fig 22. correction of logical error 1 ............................................................. 40


Programming CS4001NI

1. Introduction

Welcome to this advanced Java programming course, where the key idea of
inheritance will be the main emphasis. In this lesson, a class hierarchy is
introduced, consisting of two specialized child classes, "Tutor" and
"Lecturer," and a parent class, "Teacher."
A key component of effectively modelling connections is inheritance. The
"Teacher" class serves as the cornerstone, containing common
characteristics and actions for a cohesive codebase. We place a strong
emphasis on best practices for creating a scalable and modular class
hierarchy throughout the whole course to improve code reuse and
maintainability.
We will investigate the development of two specialized child classes,
"Lecturer" and "Tutor," each suited to a different position in the classroom.
See how inheritance and polymorphism may be used to create a codebase
that is both resilient and flexible. Come along on this adventure to improve
your Java programming abilities by fusing theory with real-world application
to ensure project success.

Fig 1 classes 1

1
Programming CS4001NI

2. Class Diagram

Class diagrams are used to show links between the objects in a framework.
Classes, variables, and connections are all addressed in the framework
hierarchy and organization charts for courses. A lesson is attended using a
rectangle structure on a class graph, verified with the lesson title,
accompanied by a trait list and a method list.

2.1. Class diagram of parent class (Teacher)

Fig 2. Class diagram of teacher 1

2
Programming CS4001NI

2.2. Class diagram of child class (Lecturer)

Fig 3 . Class diagram of lecturer 1

3
Programming CS4001NI

2.3. Class diagram of child class(Tutor)

Fig 4 . Class diagram of tutor 1

4
Programming CS4001NI

2.4. Inherited class diagram

Fig 5 . Inherited class diagram 1

5
Programming CS4001NI

3. Pseudocode

Pseudocode is a casual way to talk about programming that doesn’t rely on


strict syntax rules or underlying technological factors. It is used to generate
a preliminary version of a program outline. Pseudocode omits the raw data
in favour of summarizing a program’s activity. System designers create
pseudocode to make sure that programmers comprehend the specifications
of a software project and align code correctly. (Anon., 2012)

According to each program’s class, the pseudocode is provided below:

3.1. Pseudocode of Teacher class

CREATE class Teacher

DECLARE six instance variables as int teacherid, String teachername,


String address, String workingtype, String employmentstatus, int
Workinghours
CREATE constructor Teacher with parameters as int teacherid, String
teachername, String address, String workingtype, String employment, int
workinghours
this.teacherid equals teacherid
this.teachername equals teachername
this.address equals address
this.workingtype equals workingtype
this.employmentstatus equals employmentstatus

DEFINE method setworkinghours(Workinghours)as int type


this.Workinghours equals workinghours
6
Programming CS4001NI

DEFINE method getteacherid(clientName) as int type


return this.teacherid
DEFINE method getteachername( ) as String type
return this.teachername
DEFINE method getaddress() as String type
return this.address
DEFINE method getworkingtype() as String type
return this.workingtype
DEFINE method getemploymentstatus() as String type
return this.employmentstatus
DEFINE method getworkinghours() as int type
return this.workinghours
DEFINE method display()
IF workinghours is not assigned
PRINT “Working Hours is Not assigned”
Else
PRINT the value of teacherid
PRINT the value of teachername
PRINT the value of address
PRINT the value of workingtype
PRINT the value of employmentstatus
PRINT the value of workinghours
END IF
END display

7
Programming CS4001NI

3.2. Pseudocode of Lecturer class

CREATE class Lecturer EXTENDS Teacher


DECLARE four variables as String department , int yearsofExperience, int
gradedscore, Boolean hasGraded

CREATE constructor Lecturer with parameters as int teacherid, String


teacherName, String address, String workingType, String
employmentStatus, int workingHours, String department, int
yearsOfExperience

CALL superclass with parameters as teacherId, teacherName, address,


workingType, employmentStatus, workingHours
this.department equals department
this. yearsOfExperience equals yearsOfExperience
setworkinghours(workingHours) as String type

DEFINE method setGradedscore (gradedScore) as int type


this.gradedScore equals Gradedscore

DEFINE method getDepartment() as String type


return this.department

DEFINE method getYearsofExperience() as int type


return this.yearsOfExperience

DEFINE method getGradedscore() as int type

8
Programming CS4001NI

return this.gradedscore

DEFINE method getHasgraded() as boolean type


return this.hasgraded
DEFINE method gradeAssignment() as void with parameters as int
gradedscore, String
department and int yearsOfexperience
IF (yearsOfExperience is greater than or equals 5 department equals
this.department)
IF (gradedscore is greater than and equals 70)
grade = “A”
IF(gradedscore is greater than and equals 60)
grade = “B”
IF(gradedscore is greater than and equals 50)
grade = “C”
IF(gradedscore is greater than and equals 40)
grade = “D”
ELSE
grade = “E”
this.gradedscore equals gradedscore
hasgraded as true
PRINT "The grade is "
ELSE
PRINT "Score has not been graded yet"
DEFINE method display()
CALL super class method display()

9
Programming CS4001NI

PRINT the value of department


PRINT the value of YearsofExperience
IF hasgraded
PRINT the value of GradedScore
PRINT “Assignment not graded yet”
END IF
END display

10
Programming CS4001NI

3.3 . Pseudocode of Tutor class

CREATE class Tutor EXTENDS Teacher

DECLARE five variables as double salary, String specialization, String


academicqualifications, int performancindex, boolean iscertified

CREATE constructor Tutor with parameters as int teacher id, String


teachername, String address, String workingtype , String
employmentstatus, int workinghours, double salary, String specialization,
String academicqualifications, int performanceindex
CALL super class with parameters as teacherid , teachername, address,
workingtype, employmentstatus and workinghours
this.salary equals salary
this specialization equals specialization
this academicqualifications equals academicqualifications
this performanceindex equals performanceindex
this iscertified equals iscertified
setworkinghours(workinghours) as String type
DEFINE method getSalary as double type
return this.salary
DEFINE method getSpecialization as String type
return this.specialization
DEFINE method AcademicQualification as String type
return this.academicqualification
DEFINE method PerformanceIndex as int type
return this.performanceindex

11
Programming CS4001NI

DEFINE method IsCertified as Boolean type


return this.iscertified
DEFINE method salary() as void with parameters as double salary, int
performanceindex

IF performanceindex greater than 5 and getworkinghours greater than 20

If performanceindex greater than or equal to 5 and performanceindex less


than or equal to 7
this.salary equals salary * 0.05

ELSE If performanceindex greater than or equal to 8 and


performanceindex less than or equal to 9

this.salary equals salary * 0.1

ELSE

this.salary equals salary * 0.2

this.iscertified equals true

ELSE

PRINT Salary cannot be approved. Tutor hasnot been certified yet.

12
Programming CS4001NI

END IF

DEFINE method removeTutor()

this.salary equals 0

this.specialization equals empty

this.academicqualification equals empty

this.performanceindex equals 0

this.iscertified equals false

DEFINE method display()

IF iscertified

CALL super class method display()

ELSE

PRINT the value of salary

13
Programming CS4001NI

PRINT the value of specialization

PRINT the value of academicqualification

PRINT the value of performanceindex

END IF

END display

14
Programming CS4001NI

4. Method Description

4.1. Method description of Teacher


Table 1 Method description of Teacher

Teacher Class (Parent Class)


Teacher (int teacherid, String This method accepts six
teachername, String address, parameters and also initializes
String workingtype, String attributes in the constructor by
employmentstatus, assigning value as parameter.
int Workinghours):
setworkinghours(Workinghours): This method accepts parameter as
String and set the value for
Workinghours.
getteacherid(): This method returns the value of
attribute
teacherid as integer.
getteachername(): This method returns the value of
attribute teachername as String.

getaddress(): This method returns the value of


attribute address as String.

getworkingtype(): This method returns the value of


attribute workingtype as String.

getemploymentstatus(): This method returns the value of


attribute employmentstatus as
String.
getworkinghours(): This method returns the value of
attribute workinghours as integer.
Void Display(): This method is used to display the
result and IF value of class

15
Programming CS4001NI

4.2. Method description of lecturer


Table 2 Method description of lecturer

Lecturer (Child Class)


Lecturer(String department, int This method accepts ten
yearsOfExperience, int parameters and also initializes
gradedscore,Boolean attributes in the constructor by
hasgraded,int teacherid, String assigning value as parameter.
teacherName, String address,
String workingType, String
employmentStatus, int
workingHours):
setworkinghours(workinghours): This method accepts parameter of
workinghours as integer and set the
value for workinghours.
getDepartment(): This method returns the value of
attribute Department as String.
getYearsofExperience(): This method returns the value of
attribute YearsofExperience as
integer.
getGradedscore(): This method returns the value of
attribute Gradedscore as integer.
getHasgraded(): This method returns the value of
attribute Hasgraded as Boolean.

setGradedscore(int gradedScore) This method accepts parameter of


gradedscore as integer and set the
value for gradedscore.
gradeAssignment(int This is a method to assign grade.
gradedscore,String department,
int yearsofExperience)
Void display(): This method is used to display the
result and IF value of class.

16
Programming CS4001NI

4.3. Method description of Tutor

Table 3 Method description of Tutor

Tutor(Child Class)
Tutor(double salary, String This method accepts eleven
specialization, parameters and also initializes
String academicqualifications, attributes in the constructor by
int performanceindex, boolean assigning value as parameter.
iscertified
Int teacherid, String
teachername, String address,
String workingtype,String
employmentstaus, int
workinghours)
getSalary(): This method returns the value of
attribute Salary as double.
getSpecialization(): This method returns the value of
attribute Specialization as String.
getAcademicQualification(): This method returns the value of
attribute
AcademicQualification as String.
getPerformanceIndex(): This method returns the value of
attribute PerformanceIndex as
integer.
getIsCertified(): This method returns the value of
attribute IsCertified as boolean.
setSalaryAndCertidy(double This method accepts parameter of
salary, int performanceindex): Tutor as String and set the value
Void removeTutor(): This method remove a tutor and
display the result.

17
Programming CS4001NI

5. Test
Running a program under test involves looking for faults, mistakes, and
security vulnerabilities. It assists us in making changes to or application and
enhancing the user interface.
5.1. Test 1
Objective To inspect lecturer class, grade the assignment, re-
inspect the lecturer class
Action Call constructor of lecturer class:
teacherid = 23045

teachername = “Ram”

address= “Kathmandu”

workingtype= “Fulltime”

employmentstatus= “Fulltimeemployee”

workinghours= 7

department= “Computing”

yearsOfExperience= 6

Expected The Lecturer would be grading the assignment.


Result
Actual The Lecturer graded the assignment.
Result
Conclusion Test successful.

In this test, lecturer was inspected before and grade the assignment and
re-inspected

18
Programming CS4001NI

Fig 6. calling constructor of lecturer 1

Fig 7. Inspection of lecturer 1

19
Programming CS4001NI

Fig 8. adding value to gardeassignment 1

fig 9 . reinspection of lecturer 1

20
Programming CS4001NI

21
Programming CS4001NI

5.2. Test 2
In this test, the Tutor class was inspected, salary was set and the Tutor
class was reinspected

Objective To inspect the Tutor class, set


salary and re-inspect the Tutor
class
Action The Tutor class is called with
following arguments:
teacherid: 23045

teachername:”Ram”

address:”Kathmandu”

workingtype: “Fulltime”

employmentstatus:
“Fulltimeemployee”

workinghours: 22

salary: 20000:00

specialization: “Maths”

academicqualifications: “Bachelor”

performanceindex: 7
Inspection of Tutor class
Void setsalary is called following
arguments
Salary = 20000.00
Performanceindex = 7
Re-inspection of Tutor class

22
Programming CS4001NI

Expected result- Tutor will set the salary


Actual result- Tutor set the salary

Conclusion - The test is successful

23
Programming CS4001NI

Fig .9.1.Adding value to the constructor 1

24
Programming CS4001NI

fig 10.inspection of tutor class 1

25
Programming CS4001NI

Fig11.settingsalary and performanceindex 1

26
Programming CS4001NI

fig 12. reinspection of tutor class 1

27
Programming CS4001NI

fig 13. adding result of tutor 1

28
Programming CS4001NI

5.3. Test 3
In this test, the Tutor class was again inspected after removing tutor

Objective To inspect tutor class again after


removing the tutor
Action The tutor class is removed.
Inspection of tutor class
Expected result Tutor would be removed

Actual result Tutor is removed

Conclusion The test is successful.

29
Programming CS4001NI

fig 14 . reinspection after removal 1

30
Programming CS4001NI

5.4. Test 4

Objective To Display details of Tutor and


Lecturer classes
Action The void display() method is called
on Tutor.
The void display() method is called
on lecturer.
Expected Result The details of Tutor and Lecturer
classes will be displayed.
Actual Result The details of Tutor and Lecturer
classes are displayed.

Conclusion Test is successful.

In this test, the details of Tutor and Lecturer class is displayed.

31
Programming CS4001NI

fig 15. details of tutor 1

32
Programming CS4001NI

fig 16. details of lecturer 1

33
Programming CS4001NI

6. Error Detection and Correction

It's undeniable that even the most knowledgeable and experienced


programmers
produce errors, which are gaffes or defects in the code that cause our
software to
act oddly. Programming issues are referred to as bugs, and eliminating
bugs from
a program is the process of doing so. There are several kinds of errors,
including:
1. Syntax error
2. Semantic error
3. Logical error
6.1. Syntax error

A mistake in a program's source code is known as a syntax error. Any portions of


the code that do not meet the syntax of the computer language will result in a
syntax error since computer programs must follow a strict syntax in order to
compile successfully (Anon., 2023)

34
Programming CS4001NI

fig 17. syntax error 1

35
Programming CS4001NI

fig 18. correction of syntax error 1

36
Programming CS4001NI

6.2. Semantic Error


The mistakes that happen when a sentence lacks meaning are known as
semantic errors.

fig 19. semantic error 1

37
Programming CS4001NI

fig 20. correction of semantic error 1

38
Programming CS4001NI

6.3. Logical Error

A program might perform wrongly or unexpectedly due to a mistake in its source


code known as a logic error (or logical error). It's a type of runtime mistake that
can make a program crash or just provide the wrong outcome (Anon., 2012)

fig 21.logical error 1

39
Programming CS4001NI

fig 22. correction of logical error 1

40
Programming CS4001NI

7. Conclusion
.
The project defines three classes: Teacher, Tutor, and Lecturer, with each
inheriting from the Teacher class. The Teacher class contains basic
information such as an ID, name, address, working type, employment
status, and working In this project, Java object-oriented programming was
the main focus .The main concept of this project was to use inheritance to
link child and parent classes. There were many methods for creating and
displaying classes, determining valuations for different types of attributes,
etchours. The Tutor class extends Teacher class, adding attributes like
salary, specialization, academic qualifications, performance index, and
certification status. The Lecturer class, which extends Teacher, includes
characteristics unique to lecturers such as department, yearsofexperience,
gradedscore and graded status.
The project includes methods for configuring and retrieving various
properties, as well as methods for grading assignments in the Lecturer
class. Additionally, there are techniques for certifying tutors based on
performance and working hours, as well as removing tutors who are not
certified.
Display methods are used to print out. This course covers object-oriented
programming. This is my first programming course. I began the coursework
by programming the software, then gradually developed my mental
framework and created a basic outline of the assignment. First of all, I was
completely ignorant about pseudo code, mistakes, and inspection. To learn
the material, I used internet resources and lecture lessons. The technique
explanation similarly baffled me .I first struggled a lot with both logical and
semantic issues. As a result, I have issues while viewing the item. I now
fully understand how methods, constructors, attributes, and other concepts
are used. Additionally, because I used Blue J to write my scripts on it, I
have a clear understanding of how to utilize it correctly. Overall, I've
learned a lot from this program, which has helped me advance my
knowledge and abilities.

41
Programming CS4001NI

8. Appendix

8.1. Teacher

public class Teacher{

//attributes of class teacher


private int teacherid;
private String teachername;
private String address;
private String workingtype;
private String employmentstatus;
private int Workinghours;

//parameters declaration for constructor


public Teacher(int teacherid,String teachername,String address,String
workingtype,String employmentstatus,int workinghours){
this.teacherid= teacherid;
this.teachername= teachername;
this.address= address;
this.workingtype= workingtype;
this.employmentstatus= employmentstatus;
this.Workinghours= 0;
}

//method to set workinghours


public void setworkinghours(int Workinghours){
this.Workinghours= Workinghours;}//this method accepts the parameter
and sets the value for workinghours.

//accessor method

public int getteacherid(){


return this.teacherid;//this method returns the value of teacherid.
}
public String getteachername(){
return this.teachername;//this method returns the value of teachername.
}
42
Programming CS4001NI

public String getaddress(){


return this.address;// this method returns the value of address.
}
public String getworkingtype(){
return this.workingtype;// this method returns the value of workingtype.
}
public String getemploymentstatus(){
return this.employmentstatus;//this method returns the value of
employmentstatus.
}
public int getWorkinghours(){
return this.Workinghours;//this method returns the value of workinghours.
}

//display method
public void display(){

//printing the details


System.out.println("Teacher ID: " + this.getteacherid());
System.out.println("Teacher name: " + this.getteachername());
System.out.println("Address: " + this.getaddress());
System.out.println("Workingtype: " + this.getworkingtype());
System.out.println("Employment status: " + this.getemploymentstatus());
if (Workinghours == 0) {
System.out.println("Working Hours is Not assigned");
} else {
System.out.println("Working Hours:"+this.getWorkinghours());
}

43
Programming CS4001NI

8.2. Lecturer

public class Lecturer extends Teacher {


// Additional attributes specific to Lecturer
private String department;
private int yearsOfExperience;
private int gradedscore;
private boolean hasgraded;

// Constructor for Lecturer class

public Lecturer(int teacherId, String teacherName, String address, String


workingType, String employmentStatus, int workingHours, String
department, int yearsOfExperience) {
super(teacherId, teacherName, address, workingType,
employmentStatus, workingHours); // Call to superclass constructor
this.department = department;
this.yearsOfExperience = yearsOfExperience;
this.gradedscore=0;
this.hasgraded= false;
setworkinghours(workingHours);
// Additional initialization specific to Lecturer can be done here

//getter
public String getDepartment(){
return this.department;//This method returns the value of department
}
public int getYearsofExperience(){
return this.yearsOfExperience;//This method returns the value of
yearsOfExperience
}
public int getGradedscore(){
return this.gradedscore;//This method returns the value of gradedscore
}
public boolean getHasgraded(){
return this.hasgraded;//This method returns the value of hasgraded
44
Programming CS4001NI

}
//setter
//setting the value of attributes**/
public void setGradedscore(int gradedScore){
this.gradedscore = gradedScore;
}

// Method to grade assignments


public void gradeAssignment(int gradedscore, String department, int
yearsOfExperience)
{
String grade;

if (yearsOfExperience >= 5 && this.department.equals(department)){


if (gradedscore >= 70 ){
grade = "A";
}
else if (gradedscore >= 60 ){
grade = "B";
}
else if (gradedscore >= 50 ){
grade = "C";
}
else if (gradedscore >= 40 ){
grade = "D";
}
else{
grade = "E";
}
this.gradedscore = gradedscore;
hasgraded = true;
System.out.println("The grade is "+grade);

}
else{
System.out.println("Score has not been graded yet");
}
}

//overriding the methods of Teacher


45
Programming CS4001NI

public void display(){


//calling display method from parent class

super.display();
System.out.println("Department:"+this.getDepartment());
System.out.println("Years of Experience:"+this.getYearsofExperience());
if(hasgraded){
System.out.println("Graded score:"+ this.getGradedscore());
} else{
System.out.println("Assignment not graded yet.");
}

}
}

8.2. Tutor
public class Tutor extends Teacher {

//instance variables specific to tutor class


private double salary;
private String specialization;
private String academicqualifications;
private int performanceindex;
private boolean iscertified;

//constructor for tutor class


public Tutor(int teacherid, String teachername, String address, String
workingtype, String employmentstatus, int workinghours, double salary,
String specialization, String academicqualifications, int performanceindex) {
super(teacherid, teachername, address, workingtype,
employmentstatus, workinghours);
this.salary = salary;
this.specialization = specialization;
this.academicqualifications = academicqualifications;
this.performanceindex = performanceindex;
this.iscertified = false;

46
Programming CS4001NI

}
//accessor
public double getSalary()
{
return this.salary;
}

public String getSpecialization()


{
return this.specialization;
}

public String getAcademicQualification()


{
return this.academicqualifications;
}

public int getPerformanceIndex()


{
return this.performanceindex;
}

public boolean getIsCertified()


{
return this.iscertified;
}

// Setter method starts here


public void setSalaryAndCertify(double salary, int performanceindex) {

if (performanceindex > 5 && getWorkinghours() > 20) {


if (performanceindex >= 5 && performanceindex <= 7) {
this.salary += salary *0.05;
} else if (performanceindex >= 8 && performanceindex <= 9) {
47
Programming CS4001NI

this.salary += salary * 0.1;


} else if (performanceindex >= 10) {
this.salary += salary * 0.2;
}

this.iscertified = true;

} else {
System.out.println("The salary cannot be approved");
}
}

// Method to remove a tutor (if not certified) and reset attributes


public void removeTutor() {
if (!iscertified) {
this.salary = 0;
this.specialization = "";
this.academicqualifications = "";
this.performanceindex = 0;
this.iscertified = false;

} else {
System.out.println("Tutor not removed because he/she is certified");
}
}
// Method to display details
public void display() {
super.display(); // display details from parent class

if (!iscertified) {
System.out.println("Tutor not certified. Details not available.");
} else {
System.out.println("Salary: $" + salary);
System.out.println("Specialization: " + specialization);
System.out.println("Academic Qualifications: " +
academicqualifications);
48
Programming CS4001NI

System.out.println("Performance Index: " + performanceindex);


}
}
}

49
Programming CS4001NI

9. Bibliography

Anon., 2012. Anon. [Online]


Available at: https://economictimes.indiatimes.com/definition/pseudocode
[Accessed 27 04 2012].
Anon., 2012. techterms.com. [Online]
Available at: https://techterms.com/definition/logic_error
[Accessed 27 04 2012].
Anon., 2023. Anon. [Online]
Available at: https://economictimes.indiatimes.com/definition/pseudocode
[Accessed 24 01 2023].

50

You might also like