Recent Question/Assignment

Assessment details for ALL students
Assessment item 2—Assignment 2
Due date: 11 September 2014 ASSESSMENT
Weighting: 30%
Length: NA 2
Objectives
This assessment item is designed to test your understanding of arrays/arraylists, objects, classes, methods, sorting and searching.
Assessment task
Write a java application that allows the user to read, display, sort and search the total rainfall (type double, e.g. 22.50) for each of 12 months (January to December). The rainfall for all 12 months must be stored in an array/ArrayList. The application should display and execute a menu with the following options. A switch statement must be used to execute the following menu options.

1. Read the rainfall for 12 months
2. Display the rainfall for 12 months
3. Display the total rainfall and the average monthly rainfall
4. Display the month with the most rainfall
5. Display the month with the least rainfall
6. Sort the rainfall in ascending order
7. Search and display the month which has rainfall equal to the given rainfall
8. Exit from application

1. Read the rainfall for 12 months
This option allows the user to read the rainfall (e.g. 22.50) for each month from the keyboard and store it in an array/arrayList. The rainfall for all 12 months (January to December) must be read and stored. The input should be validated (e.g. if the user enters a rainfall less than 0 then an appropriate message should be displayed and the user should be asked to enter a new discount).

2. Display the rainfall for 12 months
This option displays the rainfall stored in Array/ArrayList for all 12 months.

3. Display the total rainfall and the average monthly rainfall
This option calculates the total rainfall and the average monthly rainfall. The total is calculated by adding each month’s rainfall and average is calculated by dividing the total rainfall by 12.

4. Display the month with the most rainfall
This option displays the month (e.g. February) with the most rainfall.

5. Display the month with the least rainfall
This option displays the month (e.g. January) with the least rainfall.

6. Sort the rainfall in ascending order
This option sorts the rainfall in ascending order and displays sorted rainfalls. You can use any sorting algorithm which you think is the best and covered in this course. The built-in sort algorithm should not be used.

7. Search and display the month which has rainfall equal to the given rainfall
This option searches and displays the month which has rainfall equal to the given rainfall. The application asks the user to enter the rainfall using the keyboard and searches for it. If the rainfall entered from the keyboard is found then the application displays the month/months (e.g. March) otherwise it displays an appropriate message. The built-in search algorithm should not be used.

8. Exit from application
The application should display the message “Thank you” and your student ID number and then exit from application.

The application should work in a loop to enable the user to read the rainfall for all 12 months, display the rainfall for each month, display the total rainfall and the average monthly rainfall, display the month with the most rainfall, display the month with the least rainfall, sort the rainfall in ascending order, search and display the month which has rainfall equal to the given rainfall and exit from application

Program design
Your design should adhere to the following guidelines:
• be logically correct
• be easy to read and maintain
• be well-designed
• use UML activity diagram

Your design MUST use classes and methods as listed below.

public class Rainfall
{
//fields
//get and set methods
}
public class RainfallTest
{
//Method to read the rainfall
//Method to display the rainfall
//Method to display the total rainfall and the average monthly rainfall
//Method to display the month with the most rainfall
//Method to display the month with the least rainfall
//Method to sort the rainfall in ascending order
//Method to search the rainfall and display the month

public static void main(String[] args)
{
}
}
You may add/use other methods, parameters, fields/variables, constants, etc. which you need to complete the application.
Testing
Testing is important. You should:
• List the different types of test cases.
• Display the results for each test case.
What to submit
You MUST show your tutor the progress (Rainfall.java and RainfallTest.java files) in Week 8 Tutorial and Week 9 Tutorial. If you are a distance student, you need to contact the course coordinator by e-mail.

You MUST submit on 11 September (Week 10) via Moodle course website the following files.
• Rainfall.java (this file contains java code for class Rainfall)
• RainfallTest.java (this file contains java code for class RainfallTest).
• Report.docx (this file contains a brief report that includes student name, student ID, course name, course code, UML activity diagram for menu option 5 (Display the month with the least rainfall) and test results (screenshots/test cases with results to show that your application is correctly working)).
Warning: You must submit your own assignment and correct files.
Assessment 2 marking criteria
Total Marks – 30 Marks Allocated
1 Design, logic and testing – 14
Code readability – appropriate use of comments, indentation and naming conventions 3

Declaring and using fields/variables and constants 2
Creating/declaring and using objects, methods and classes 3
Overall design and logic (structure, efficiency) 2
Validity of testing as evidenced by submitted test results 2
UML activity diagram for menu option 5 2
2 Compilation and execution - 14
(0 - if application doesn't run)
Welcome and exit messages 1
Input data validation and message 1
Read the rainfall 1
Display the rainfall 1
Display the total rainfall and the average rainfall 2
Display the month with the most rainfall 1
Display the month with the least rainfall 1
Sort the rainfall in ascending order 2
Search and display the month which has rainfall equal to the given rainfall 2
Overall program execution (user friendly, input/output and display) 2
3 Report – 2
Quality of the Report (Content, Presentation, Language) 2
4 Late submission penalty is 5% of total mark per day -1.5/day
5 Penalty for using things not covered in lectures and tutorials -3