Object-Oriented Programming Concepts

Verified

Added on  2020/04/13

|41
|3987
|234
AI Summary
This assignment tests your understanding of Object-Oriented Programming (OOP) concepts in Java. You'll be presented with a series of menu-driven options, each focusing on a specific OOP concept like class creation, inheritance, polymorphism, and more. The tasks involve implementing these concepts through Java code to solve practical programming problems. This assignment helps solidify your grasp of core OOP principles and their application in real-world scenarios.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Running Head: ICT167 PRINCIPLES OF COMPUTER SCIENCE
Murdoch University
ICT167 Principles of Computer Science
Trimester TSA, 2017
[Author]
[Date]
I would like to express my gratitude to my supervisors for the useful comments, remarks and
engagement through the learning process of this project. Furthermore, I would like to thank my
teachers for introducing me to the topic as well for the support on the way. Also, I like to thank
the participants in my survey, who have willingly shared their precious time during the process
of project development. I would like to thank my mates, who have supported me throughout
entire process. I will be grateful forever for your support.

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
1ICT167 PRINCIPLES OF COMPUTER SCIENCE
Table of Contents
Requirements/Specification 2
User Guide 2
Structure/Design/Algorithm 3
Limitations 5
Testing 5
Source Code 11
Bibliography 39
Document Page
2ICT167 PRINCIPLES OF COMPUTER SCIENCE
Requirements/Specification
In this programming the user can manage student data into the system by this
programing. The program is developed for enhance the administration of student grades as well
as sort store data into the array. In this program a user can enter the student details into the
system than this data is loaded into a data structure of student. This program has a menu of
options where the users can select them as they needed. in this menu driven program, two
different classes are used to define all functionalities of adding student, get all student details, get
average overall marks, calculate which students have above or below and equal to total average
mark, display the distribution of grades, find student by student ID as well as fund by student
first or last name, find the highest and second highest overall mark obtain the student, sort the
data structure by student ID as well as student name. Among the above mentioned functionalities
add student function, find student by student ID as well as student surname or first name
functions required user input otherwise other functions are not required any input for the user,
these are calculated by the predefine methods.
User Guide
In this section the steps are required to execute the program as well as all function. The
execution of this program is depends few aspects such as the intended system must have java
installed, then copy the both program files (student.java and client.java) into a single directory.
Then compile the student.java and client.java file by java compiler, where the user can see two
class files for both class is generated. After that user can run the program by “java client”
command from the command prompt.
Document Page
3ICT167 PRINCIPLES OF COMPUTER SCIENCE
After successfully lunch the program in command prompt the use can have eleven
different options, where user can perform all required functionalities.
Structure/Design/Algorithm
This section defines the entire structure of the program, where user find functionalities as
well as their usages. A user can select any options form the menu but only after adding student
information they can perform all functionalities. Therefore, it can be assumed that the student
data must be valid and has been entered into the system so can user perform all operation. In this
menu driven program user have an option for quit the program at any time, which helps the user
to stop execution.
Design of the program is depicting as UML sequence diagram:

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
4ICT167 PRINCIPLES OF COMPUTER SCIENCE
Algorithm for sorting method used in this application:
begin Sort Student(array)
Document Page
5ICT167 PRINCIPLES OF COMPUTER SCIENCE
for all elements of list
if array [i] > array [i+1]
swap (array [i], array [i+1])
end if
end for
return list
end Sort Student
Limitations
In this project the limitations are very few which have been identified by the developer
that if the program use database to store the data or text file then it would be used for real world
application. However, according to the learning objectives it does not have any limitation
because all type of functionalities as well as their implementation are correctly developed in this
project.
Testing
In this section of this document intended for provide evidence off every functionality of
this application. This application holds eleven type of functions in a menu items, where each
function will call a particular method to execute an operation. The application is tested as black
box testing as well as white box testing. The white box testing is attempted during the
Document Page
6ICT167 PRINCIPLES OF COMPUTER SCIENCE
development life cycle of this application. After successfully test this application by developer
end, it also tests by users therefore in this document all evidence of black box testing is shown
below.

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
7ICT167 PRINCIPLES OF COMPUTER SCIENCE
Document Page
8ICT167 PRINCIPLES OF COMPUTER SCIENCE
Document Page
9ICT167 PRINCIPLES OF COMPUTER SCIENCE

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
10ICT167 PRINCIPLES OF COMPUTER SCIENCE
Document Page
11ICT167 PRINCIPLES OF COMPUTER SCIENCE
Source Code
public class student {
//the following field are used to hold student data
String title;
String firstName;
String lastName;
long studentID;
int dday;
int dmonth;
Document Page
12ICT167 PRINCIPLES OF COMPUTER SCIENCE
int dyear;
double assignment1;
double assignment2;
double WeekPratical;
double finalExam;
double overallMarks;
String grade;
public student() //default constructor
{
}
//parameterized constructor
public student(String title, String firstName, String lastName, long studentID, int dday, int
dmonth, int year, double assignment1, double assignment2, double WeekPratical, double
finalExam, double overallMarks, String grade) {
this.title = title;
this.firstName = firstName;
this.lastName = lastName;
this.studentID = studentID;

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
13ICT167 PRINCIPLES OF COMPUTER SCIENCE
this.dday = dday;
this.dmonth = dmonth;
this.dyear = year;
this.assignment1 = assignment1;
this.assignment2 = assignment2;
this.WeekPratical = WeekPratical;
this.finalExam = finalExam;
this.overallMarks = overallMarks;
this.grade = grade;
}
//get methods all field
public String getTitle() {
return title;
}
public String getFirstName() {
return firstName;
}
Document Page
14ICT167 PRINCIPLES OF COMPUTER SCIENCE
public String getLastName() {
return lastName;
}
public long getStudentID() {
return studentID;
}
public int getDday() {
return dday;
}
public int getDmonth() {
return dmonth;
}
public int getDyear() {
return dyear;
}
public double getAssignment1() {
return assignment1;
Document Page
15ICT167 PRINCIPLES OF COMPUTER SCIENCE
}
public double getAssignment2() {
return assignment2;
}
public double getWeekPratical() {
return WeekPratical;
}
public double getFinalExam() {
return finalExam;
}
//Set methods all field
public void setTitle(String title) {
this.title = title;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
16ICT167 PRINCIPLES OF COMPUTER SCIENCE
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setStudentID(long studentID) {
this.studentID = studentID;
}
public void setDday(int dday) {
this.dday = dday;
}
public void setDmonth(int dmonth) {
this.dmonth = dmonth;
}
public void setDyear(int dyear) {
this.dyear = dyear;
}
public void setAssignment1(double assignment1) {
this.assignment1 = assignment1;
Document Page
17ICT167 PRINCIPLES OF COMPUTER SCIENCE
}
public void setAssignment2(double assignment2) {
this.assignment2 = assignment2;
}
public void setWeekPratical(double WeekPratical) {
this.WeekPratical = WeekPratical;
}
public void setFinalExam(double finalExam) {
this.finalExam = finalExam;
}
public double getOverallMarks() {
return overallMarks;
}
public String getGrade() {
return grade;
}
//calculate ovverall marks
Document Page
18ICT167 PRINCIPLES OF COMPUTER SCIENCE
public double calculateOverAllMarks()
{
this.overallMarks = (this.assignment1*0.20)+(this.assignment2*0.20)+(this.WeekPratical*0.10)+
(this.finalExam*0.50);
return overallMarks;
}
public String Grade()
{
if(this.overallMarks>=80)
{
this.grade="HD";
}
else if (this.overallMarks>=70)
{
this.grade="D";
}
else if (this.overallMarks>=60)
{

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
19ICT167 PRINCIPLES OF COMPUTER SCIENCE
this.grade="C";
}
else if (this.overallMarks>=50)
{
this.grade="P";
}
else if (this.overallMarks<50)
{
this.grade="N";
}
return grade;
}
//calculate equality
public boolean getEquality(student s1, student s2)
{
if(s1.firstName.equalsIgnoreCase(s2.firstName) &&
s1.lastName.equalsIgnoreCase(s2.lastName) &&
Document Page
20ICT167 PRINCIPLES OF COMPUTER SCIENCE
s1.dday==s2.dday && s1.dmonth==s2.dmonth && s1.dyear == s2.dyear && s1.studentID ==
s2.studentID)
{
return true;
}
else
return false;
}
}
public class client {
static int N=6;
static student []stu = new student[N];
static Scanner sc = new Scanner(System.in);
static int input=0;
static int index=0;
static double overall=0;
public static void addStudent()
Document Page
21ICT167 PRINCIPLES OF COMPUTER SCIENCE
{
if(index<=stu.length)
{
student s = new student();
System.out.println("Enter Student Details");
System.out.println("Enter Title: ");
String title = sc.nextLine();
s.setTitle(title);
System.out.println("Enter First Name: ");
String fname = sc.nextLine();
s.setFirstName(fname);
System.out.println("Enter Last Name: ");
String lname = sc.nextLine();
s.setLastName(lname);
System.out.println("Enter Student ID");
long studentID = sc.nextLong();

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
22ICT167 PRINCIPLES OF COMPUTER SCIENCE
s.setLastName(lname);
System.out.println("Enter Date of birth: ");
System.out.println("Enter Date: ");
int day = sc.nextInt();
s.setDday(day);
System.out.println("Enter Month: ");
int month = sc.nextInt();
s.setDmonth(month);
System.out.println("Enter Year: ");
int Year = sc.nextInt();
s.setDyear(Year);
System.out.println("Enter marks for assignmnet 1:");
double m1 = sc.nextDouble();
s.setAssignment1(m1);
System.out.println("Enter marks for assignmnet 2:");
double m2 = sc.nextDouble();
s.setAssignment2(m2);
Document Page
23ICT167 PRINCIPLES OF COMPUTER SCIENCE
System.out.println("Enter partical marks: ");
double m3 = sc.nextDouble();
s.setWeekPratical(m3);
System.out.println("Enter final exam marks: ");
double m4 = sc.nextDouble();
s.setFinalExam(m4);
double overall = s.calculateOverAllMarks();
String grade = s.Grade();
stu[index]=new
student(title,fname,lname,studentID,day,month,Year,m1,m2,m3,m4,overall,grade);
index=index+1;
}
else
System.out.println("Student list is full...");
}
public static void display()
{
Document Page
24ICT167 PRINCIPLES OF COMPUTER SCIENCE
for (int i=0; i<index; i++)
{
System.out.println("Student Name: "+stu[i].getTitle()+" "+stu[i].getFirstName()+"
"+stu[i].getLastName());
System.out.println("Student ID: "+stu[i].getStudentID());
System.out.println("Date of Birth: "+stu[i].getDday()+"-"+stu[i].getDmonth()
+"-"+stu[i].getDmonth());
System.out.println("Obtain Marks for Assignment 1: "+stu[i].getAssignment1());
System.out.println("Obtain Marks for Assignment 2: "+stu[i].getAssignment2());
System.out.println("Obtain Marks for Practical Work: "+stu[i].getWeekPratical());
System.out.println("Obtain Marks for Final Exam: "+stu[i].getFinalExam());
System.out.println("Overall obtain Marks: "+stu[i].getOverallMarks());
System.out.println("Grade: "+stu[i].getGrade());
}
}
public static void overallMarks()
{

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
25ICT167 PRINCIPLES OF COMPUTER SCIENCE
double sum=0;
for (int i=0; i<index; i++)
{
sum+=stu[i].getOverallMarks();
}
overall = sum/index;
System.out.println("Overall Marks for all students: "+overall);
}
public static void GreadDistribution()
{
int countHD=0;
int countD=0;
int countC=0;
int countP=0;
int countN=0;
Document Page
26ICT167 PRINCIPLES OF COMPUTER SCIENCE
for (int i=0; i<index; i++)
{
if(stu[i].getGrade().equalsIgnoreCase("HD"))
{
countHD++;
}
else if(stu[i].getGrade().equalsIgnoreCase("D"))
{
countD++;
}
else if(stu[i].getGrade().equalsIgnoreCase("C"))
{
countC++;
}
else if(stu[i].getGrade().equalsIgnoreCase("P"))
{
countP++;
Document Page
27ICT167 PRINCIPLES OF COMPUTER SCIENCE
}
else if(stu[i].getGrade().equalsIgnoreCase("N"))
{
countN++;
}
}
System.out.println("Number Grades HD: "+countHD+ "| D: "+countD+"| C:"+countC+"|
P:"+countP+"| N:"+countN);
}
public static void ShowOverallMarks()
{
overallMarks();
int countAboveOverall=0;
int countBelowOverall=0;
for (int i=0; i<index; i++)
{
if(stu[i].getOverallMarks()>=overall)

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
28ICT167 PRINCIPLES OF COMPUTER SCIENCE
{
countAboveOverall++;
}
else
{
countBelowOverall++;
}
}
System.out.println("Number of Student get equal or above average overall Marks:
"+countAboveOverall);
System.out.println("Number of Student get equal or below average overall Marks:
"+countBelowOverall);
}
public static void FindStudentByID()
{
System.out.print("Student ID: ");
long sid = sc.nextLong();
for (int i=0; i<index; i++)
Document Page
29ICT167 PRINCIPLES OF COMPUTER SCIENCE
{
if(stu[i].getStudentID()==sid)
{
System.out.println("Student Name: "+stu[i].getTitle()+" "+stu[i].getFirstName()+"
"+stu[i].getLastName());
System.out.println("Student ID: "+stu[i].getStudentID());
System.out.println("Date of Birth: "+stu[i].getDday()+"-"+stu[i].getDmonth()
+"-"+stu[i].getDmonth());
System.out.println("Obtain Marks for Assignment 1: "+stu[i].getAssignment1());
System.out.println("Obtain Marks for Assignment 2: "+stu[i].getAssignment2());
System.out.println("Obtain Marks for Practical Work: "+stu[i].getWeekPratical());
System.out.println("Obtain Marks for Final Exam: "+stu[i].getFinalExam());
System.out.println("Overall obtain Marks: "+stu[i].getOverallMarks());
System.out.println("Grade: "+stu[i].getGrade());
}
}
}
public static void FindStudentByName()
Document Page
30ICT167 PRINCIPLES OF COMPUTER SCIENCE
{
System.out.print("Student Name: ");
String sName = sc.nextLine();
for (int i=0; i<index; i++)
{
if(stu[i].getFirstName().equalsIgnoreCase(sName) ||
stu[i].getLastName().equalsIgnoreCase(sName))
{
System.out.println("Student Name: "+stu[i].getTitle()+" "+stu[i].getFirstName()+"
"+stu[i].getLastName());
System.out.println("Student ID: "+stu[i].getStudentID());
System.out.println("Date of Birth: "+stu[i].getDday()+"-"+stu[i].getDmonth()
+"-"+stu[i].getDmonth());
System.out.println("Obtain Marks for Assignment 1: "+stu[i].getAssignment1());
System.out.println("Obtain Marks for Assignment 2: "+stu[i].getAssignment2());
System.out.println("Obtain Marks for Practical Work: "+stu[i].getWeekPratical());
System.out.println("Obtain Marks for Final Exam: "+stu[i].getFinalExam());
System.out.println("Overall obtain Marks: "+stu[i].getOverallMarks());

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
31ICT167 PRINCIPLES OF COMPUTER SCIENCE
System.out.println("Grade: "+stu[i].getGrade());
}
}
}
public static void ShowHighest_SecondHighest()
{
double largest = stu[0].getOverallMarks();
double secondLargest = stu[0].getOverallMarks();
String studentName1 ="";
String studentName2 ="";
for (int i = 0; i < index; i++) {
if (stu[i].getOverallMarks() > largest) {
secondLargest = largest;
largest = stu[i].getOverallMarks();
studentName1=stu[i].getTitle()+" "+stu[i].getFirstName()+" "+stu[i].getLastName();
Document Page
32ICT167 PRINCIPLES OF COMPUTER SCIENCE
} else if (stu[i].getOverallMarks() > secondLargest) {
secondLargest = stu[i].getOverallMarks();
studentName2=stu[i].getTitle()+" "+stu[i].getFirstName()+" "+stu[i].getLastName();
}
}
System.out.println(studentName1+" with the Highest Overall Marks " + largest);
System.out.println(studentName2+" with the Second Highest Overall Marks " + secondLargest);
}
public static void SortStudentID()
{
for (int i = 0; i < index; i++) {
for (int j = i + 1; j < index; j++) {
student tmp;
if (stu[i].getStudentID() > stu[j].getStudentID())
{
tmp = stu[i];
Document Page
33ICT167 PRINCIPLES OF COMPUTER SCIENCE
stu[i] = stu[j];
stu[j] = tmp;
}
}
}
display();
}
public static void SortStudentName()
{
int j;
boolean flag = true; // will determine when the sort is finished
student temp;
while ( flag )
{
flag = false;
for ( j = 0; j < index - 1; j++ )
{

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
34ICT167 PRINCIPLES OF COMPUTER SCIENCE
if ( stu [ j ].getFirstName().compareToIgnoreCase( stu [ j+1 ].getFirstName() ) > 0 )
{
temp = stu[ j ];
stu[ j ] = stu [ j+1];
stu [ j+1] = temp;
flag = true;
}
}
}
display();
}
public static void DisplayMenu()
{
System.out.println("Student Grade Menu");
System.out.println("1. Quit");
System.out.println("2. Add Student");
System.out.println("3. Show Student Data");
Document Page
35ICT167 PRINCIPLES OF COMPUTER SCIENCE
System.out.println("4. Show Overall Marks");
System.out.println("5. Student have above & below Overall Marks");
System.out.println("6. Show distribution of grades");
System.out.println("7. Find Student by student ID");
System.out.println("8. Find Student by student name");
System.out.println("9. Find students with the highest overall mark and the second highest overall
mark");
System.out.println("10. Sort Student by student ID");
System.out.println("11. Sort Student by student Surname");
System.out.print("Enter Choice:");
}
public static void main(String args[])
{
while(1!=input)
{
DisplayMenu();
input = sc.nextInt();
sc.nextLine();
Document Page
36ICT167 PRINCIPLES OF COMPUTER SCIENCE
switch(input)
{
case 1:
input =1;
break;
case 2:
addStudent();
break;
case 3:
display();
break;
case 4:
overallMarks();
break;
case 5:
ShowOverallMarks();
break;

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
37ICT167 PRINCIPLES OF COMPUTER SCIENCE
case 6:
GreadDistribution();
break;
case 7:
FindStudentByID();
break;
case 8:
FindStudentByName();
break;
case 9:
ShowHighest_SecondHighest();
break;
case 10:
SortStudentID();
break;
case 11:
SortStudentName();
Document Page
38ICT167 PRINCIPLES OF COMPUTER SCIENCE
break;
default:
System.out.println("you have entered wrong choice..");
}
}
}
}
Document Page
39ICT167 PRINCIPLES OF COMPUTER SCIENCE
Bibliography
Barnes, D. J., Kölling, M., & Gosling, J. (2017). Objects first with Java: A practical introduction
using Bluej. Pearson.
Clarke, D., Wrigstad, T., & Noble, J. (Eds.). (2013). Aliasing in Object-oriented Programming:
Types, Analysis and Verification (Vol. 7850). Springer.
Corral, J. M. R., Balcells, A. C., Estévez, A. M., Moreno, G. J., & Ramos, M. J. F. (2014). A
game-based approach to the teaching of object-oriented programming languages.
Computers & Education, 73, 83-92.
Dale, N., Joyce, D. T., & Weems, C. (2016). Object-oriented data structures using Java. Jones &
Bartlett Publishers.
Koscielny, J., Holthusen, S., Schaefer, I., Schulze, S., Bettini, L., & Damiani, F. (2014,
September). DeltaJ 1.5: delta-oriented programming for Java 1.5. In Proceedings of the
2014 International Conference on Principles and Practices of Programming on the Java
platform: Virtual machines, Languages, and Tools (pp. 63-74). ACM.
Liang, Y. D. (2013). Introduction to Java programming: brief version. Pearson.
Odersky, M., & Rompf, T. (2014). Unifying functional and object-oriented programming with
scala. Communications of the ACM, 57(4), 76-86.
Schmidt, D. C., Stal, M., Rohnert, H., & Buschmann, F. (2013). Pattern-Oriented Software
Architecture, Patterns for Concurrent and Networked Objects (Vol. 2). John Wiley &
Sons.

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
40ICT167 PRINCIPLES OF COMPUTER SCIENCE
Thüm, T., Kästner, C., Benduhn, F., Meinicke, J., Saake, G., & Leich, T. (2014). FeatureIDE: An
extensible framework for feature-oriented software development. Science of Computer
Programming, 79, 70-85.
Zhang, Y., Loring, M. C., Salvaneschi, G., Liskov, B., & Myers, A. C. (2015, June).
Lightweight, flexible object-oriented generics. In ACM SIGPLAN Notices (Vol. 50, No.
6, pp. 436-445). ACM.
1 out of 41
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]