Coit20245 T123 Ass2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Assessment details COIT 20245

Assessment item 2—JAVA Program using an array of


objects
Due date: Week 10 T123 – Midnight, Friday (19/5/23) ASSESSMENT

Refer below for complete assessment item 2 requirements.


(Assignment Two)
Weighting: 30%

Length: N/A 2
Objectives
This assessment item relates to the unit learning outcomes as stated in the Unit Profile.

Details
For this assignment, you are required to develop a Menu Driven Console Java Program to
demonstrate you can use Java constructs including input/output via the console, Java primitive and
built-in types, Java defined objects, arrays, selection and looping statements and various other Java
commands. Your program must produce the correct results.
The code for the menu and option selection is supplied: RockyCollegeMenu.java and is available
on the unit website, you must write the underlying code to implement the program. The menu
selections are linked to appropriate methods in the given code. Please spend a bit of time looking at
the given code to familiarise yourself with it and where you must complete the code. You will need to
write comments in the supplied code as well as your own additions.

What to submit for this assignment

Please submit your source code as a zip or your zipped Netbeans project folder.

o Ass2.zip

A report including an UML class diagram of just your Student class only, how long it took to create
the whole program, any problems encountered, and screenshots of the output produced including
annotations of your testing. (Use Alt-PrtScrn to capture just the application window and you can paste
it into your Word document) You should create a test plan and test every possibility in the program
including known results. You need to show the results of the testing. Also please include your code as
text in the appendix.
o ReportAss2.docx

You will submit your files by the due date using the “Assignment 2” link on the Moodle unit website
under Assessment … Assignment 2 Submission.

COIT20245, 2023 Term One - Page 1 of 13


Assignment Specification
You have completed the assignment one console program for processing students for the Rocky
Colleges. We are going to extend this application so the students names and mark can be stored in an
array of objects, do not use ArrayList. For this assignment we will also read the student’s ID code.

The program will run via a menu of options, the file RockyCollegeMenu.java has been supplied (via
the Moodle web site) which supplies the basic functionality of the menu system.

Look at the code supplied and trace the execution and you will see the menu is linked to blank
methods (stubs) which you will implement the various choices in the menu.

Student class
First step is to create a class called Student (Student.java).

The Student class will be very simple it will contain three private instance variables:
o studentName as a String
o studentID as an integer
o studentMark as a double

The numeric literal values maximum students, minimum and maximum marks (i.e. zero and one
hundred), the different grades cut-offs, the different rebate percentage values and unit charge must be
represented as constants.

The following public methods will have to be implemented:


o A default constructor
o A parameterised constructor
o Three set methods (mutators)
o Three get methods (accessors)
o A method to calculate and return the grade for the student – calculateGrade(). Also, a method
for calculating the rebate – calculateRebate() (use calculateGrade() to get the grade for this
calculation). These calculations will be the same as in assignment one. Use constants for all
numeric literals.

You should use the following method headers:

public String calculateGrade()

A mark greater than or equal to 85 the grade will be “HD”.

A mark greater than or equal to 75 and less than 85 the grade will be “D”.

A mark greater than or equal to 65 and less than 75 the grade will be “C”.

A mark greater than or equal to 50 and less than 65 the grade will be “P”.

A mark less than 50 the grade will be “F”.

public double calculateRebate()

The charge for each unit is $2,000.

COIT20245, 2023 Term One - Page 2 of 13


Rocky College wants to reward high achieving students by giving them a rebate on the unit charge as
follows:

A student which receives a grade of “HD” will receive a rebate of 10% on their unit charge.

A student which receives a grade of “D” will receive a rebate of 5% on their unit charge.

A student which receives a grade of “C” will receive a rebate of 2% on their unit charge.

Students with a grade of “P” or “F” will not receive any rebate.

Note: you do not need to pass the mark as a parameter as you can access the instance variables
directly within the class. The calculations will be the same as assignment one:

Note: Following basic database principles, calculated values are not usually stored, so in this case we
will not store the grade or rebate as a instance variables, but use the calculateGrade() and
calculateRebate() methods when we want to determine the grade and rebate.

Rocky College menu program.

Rocky College offers diploma courses (one year) for easy entry into university courses. Major
universities have agreed to give students full credit for the units they have studied at Rocky College.

Rocky College boasts small class sizes, state of the art facilities and one on one help if required.

Initially (only once at the beginning of the program), the coordinator will be prompted to enter the
unit code for their unit. You must write a validation loop to ensure the unit code is not empty. This
will happen before the menu is displayed.

COIT20245, 2023 Term One - Page 3 of 13


RockyCollegeMenu class
Once the Student class is implemented and fully tested, we can now start to implement the
functionality of the menu system. You must only use techniques which have been covered in this
unit or you could lose substantial marks.

Data structures
For this assignment we are going to store the student names, student IDs and marks in an array of
Student objects.
Declare an array of Student objects as an instance variable of RockyCollegeMenu class the array
should hold ten students.
You will need another instance variable (integer) to keep track of the number of the students being
entered and use this to keep track of the number of entries in the array of Student objects.

Menu options
1. Enter student name, student ID and mark: enterStudent()
You will read in the student’s name, student ID and mark.

Data validation (you can implement this after you have got the basic functionality implemented)
You will need to validate the user input using a validation loop.
The student’s name cannot be blank i.e. not an empty string or null. The student ID cannot be blank
and must be numeric (integer) (hint: read this in as a string use the isStringNumeric(idStr) method
supplied in the skeleton code and use Integer.parseInt(idStr) to return the integer once verified). The
mark needs to be greater than or equal to zero and less than or equal to one hundred, the same as
assignment one.

COIT20245, 2023 Term One - Page 4 of 13


When the student’s name, student ID and marks have been entered successfully into three local
variables you will need create a Student object using the new keyword and the parameterised
constructor and add it to the Student array, you will also need to increment a counter to keep track of
the number of students you have entered and the position in the array of the next student to be entered.

When the maximum number of students is reached do not attempt to add any more students and give
the following error message:

COIT20245, 2023 Term One - Page 5 of 13


When the student details have been successfully entered, display the details of the student and the
grade and rebate as follows:

Hint: use the format string in printf of "%-30s%-12d%-11.2f%-6s$%5.2f\n"). This will line
up the output correctly under the heading.

COIT20245, 2023 Term One - Page 6 of 13


Note: For the next three options, display all, statistics and search you should ensure at least one
student has been entered and give an appropriate error message if it there are no students entered and
for the sorting option you must ensure at least two students have been entered, for example:

COIT20245, 2023 Term One - Page 7 of 13


2. Display all student names, student IDs, marks, grades and rebates:

displayAllStudents()

When this option is selected display all the students which have been entered so far.

COIT20245, 2023 Term One - Page 8 of 13


3. Display statistics: displayStatistics()
When this option is selected you will display the statistics as per assignment one. You can loop
through your array of objects to calculate this information.

COIT20245, 2023 Term One - Page 9 of 13


4. Search for a student by student ID: searchStudentss()
You can just use a simple linear search.

If the search is successful display the details about the student.

If the search is unsuccessful display an appropriate message.

COIT20245, 2023 Term One - Page 10 of 13


5. Sort the students: sortStudents()

This option you will sort the students alphabetically (case insensitive) by the student names, you can
use any sorting algorithm which you like, do not use any in-built sort methods. Display the sorted
list after the sort is complete.

Remember the welcome and exit messages as per assignment one.

COIT20245, 2023 Term One - Page 11 of 13


Extra Hints
Your program should be well laid out, commented and use appropriate and consistent names (camel
notation) for all variables, methods and objects.
Make sure you have no repeated code (even writing headings in the output)
Constants must be used for all numbers (numeric literals) in your code.
Look at the marking criteria to ensure you have completed all of the necessary items.
Refer to a Java reference textbook and the unit and lecture material (available on the unit web
site) for further information about the Java programming topics required to complete this assignment.
Check output, check code and add all of your comments, complete report and the UML class diagram.
Supplied Code
Download, compile and run the supplied code available from the unit web site.
You will see the menu interface has been implemented and you have to implement the underlying
code, use the supplied method stubs and add your own methods.
Follow the // TODO comments in the supplied code.
Again no code should be repeated in your program.

If you just submit the supplied code you will receive zero marks.

Good luck! Bruce McKenzie Unit Coordinator T123 COIT20245

[email protected]

Marking scheme is on the following page.

COIT20245, 2023 Term One - Page 12 of 13


Total number of marks – 30
Variables, constants, and types
Variables have meaningful names and use camel notation 0.5
Constants are used for all numeric literals 1
Array of objects is used 1
Code in general
Code is indented and aligned correctly, and is easy to read 1
Code has header comment which includes name, student ID, date,
file name and purpose of the class 0.5
Code is fully commented including all variables and methods 1
No repeated code 1
Student class
Instance variables are correct and private 0.5
Default and parameterised constructors are correct 0.5
Method for calculating the grade is correct 0.5
Method for calculating the rebate is correct 0.5
Get and set methods are correct 1
RockyCollegeMenu class -- Enter student
Student name is read correctly 0.25
Student ID is read correctly 0.5
Mark is read correctly 0.25
Data is added to the object array correctly 1.5
Output resembles the specification (two decimal points) 1
Error when maximum students is reached 0.5
Error when student name not entered 0.5
Error when student ID is incorrect 0.5
Error when the mark is less than zero or greater than 100 0.5
Data validation loops are correct 0.5
Display all students
All records displayed 2
Output resembles the specification 1
Display statistics
Maximum and minimum are correct including the student names 1
Average is correct 0.5
Total rebates is correct 0.5
Output resembles the specification (two decimal points) 0.5
Search
Search is correct and correct details returned 1.5
“<search key> not found” is correct 0.5
Sort
Sort is correct and inbuilt sorting methods are not used 1.5
Sort is case insensitive 0.5
Sorted list is displayed after sort 0.5
General
Welcome and exit message (as per assignment one) 0.5
No students entered is handled correctly 0.5
Correct files submitted 0.5
Report
UML class diagram of Student class is correct 1
Screen shot(s) of testing and testing plan including known results 2
Report presentation and comments including how long it had taken
and any problems encountered 0.5

COIT20245, 2023 Term One - Page 13 of 13

You might also like