Assignment
Overview
This is an individual assignment that requires you to design, develop and test a small procedural Java program.
Learning Outcomes Assessed
The following course learning outcomes are assessed by completing this assessment:
- Identify and use the correct syntax of a common programming language
- Recall and use typical programming constructs to design and implement simple software solutions
- Reproduce and adapt commonly used basic algorithms
- Utilise pseudocode and/or algorithms as a major program design technique
- Write and implement a solution algorithm using basic programming constructs
- Demonstrate debugging and testing skills whilst writing code
- Develop self-reliance and judgement in adapting algorithms to diverse contexts
- Design and write program solutions to identified problems using accepted design constructs
Assessment Details
Your task is to design, develop and test a small application for Santa. Christmas is only weeks away and Santa has decided to open his own Christmas Parcel Delivery System. His first task is to develop a Christmas Parcel Delivery Calculator. The Calculator will allow his elves to setup a travel surcharge, enter parcels and display the end delivery costs.
Stage 1: Design
This stage requires you to prepare documentation that describes the function of the program and how it is to be tested. There is no coding or code testing involved in this stage. A document template has been provided for your use.
Requirements:
1) Read through Stage 2: Program Development to obtain details of the requirements of this program.
2) Write an algorithm that describes how the program will operate.
a. All program requirements - base, standard and advanced - must be included, even if you do not end up including all these requirements in your program code.
b. The algorithm must be structured logically so that the program would function correctly.
3) Prepare and document test cases that can be used to check that the program works correctly, once it has been coded. You do NOT need to run the test cases in this stage; this will occur in Stage 3: Testing.
a. All program requirements - base, standard and advanced, must be included, even if you do not end up including all these requirements in your program code.
b. Make sure the test cases include checking of data entered by the user to make sure that only valid data is accepted. If the user enters invalid data, the user should be informed of this and given another chance to enter the data. NB: As we have not covered exception handling, you may assume that the user will always enter an integer.
c. Test cases should be documented using a template like the one below. You may include extra information if you wish. At this stage, the Actual Result column will be left blank.
Test Case
|
Expected Result
|
Actual Result
|
The user selects the menu option: Setup
|
The user is prompted to
|
|
Cost Per KM
|
enter the travel cost (per
|
|
KM) for a package sent
|
|
under 100KM.....
|
Stage 2: Program Development
Using the Design Documentation to assist you, develop a Java program that allows a user to set up transport (travel) costs, enter a parcels details and then calculates the total cost of sending the parcel. These requirements have been broken into three groups:
- Base Functionality includes the minimal level of requirements to achieve the essential components of this assignment. This group of requirements focuses on getting the code to work and on using the programming constructs we cover in class. You can expect to use constants, variables, loops, conditional statements and arithmetic operators for these requirements and you should look for opportunities to use these wherever you can. You will not receive full marks for implementing a requirement (even if it works) if you have not used the appropriate programming construct to do so.
At this level, you can decide if it is easier for you to code everything within a single method, or to modularize it straight away.
- Standard Functionality ensures the code is modularized, and that method calls are used to ensure the program flows correctly. It allows data to pass from one method to another as parameters.
- Advanced Functionality provides a challenge task, and is best left until all the other requirements have been addressed. It requires looking at a Java API to find out how to use a class we have not covered in the course, and using this to calculate the delivery date.
You are expected to follow coding conventions, such as proper layout of code, use naming conventions and write meaningful comments throughout your program.
Base Functionality:
1) Display a welcome message when the program starts
- The welcome message should have a row of minus (-) and plus (+) signs at the top and the bottom, just long enough to extend over the text. Hint: Use a For loop for this.
- The second line of the message should read "FEDERATION UNIVERSITY - " and then your location e.g. Mt Helen, IIBIT Sydney, MIT Melbourne. This message should be approximately centred by printing white space first. Hint: Can you modify the For loop from the previous step to print the white spaces?
- The third line of the message should be blank.
- The fourth line should read "Christmas Parcel Delivery Calculator" and should be approximately centred.
- The fifth line of the message should be blank
- The sixth line should read "Developed by" followed by your name and a comma, then " Student ID ", then your student id, then finally " for ITECH1000 Summer 2017".
- The seventh line should be blank.
- The last line should be a repeat of minus (-) and plus (+) signs
2) Provide a menu from which the user can select to setup travel costs, enter a parcel's details, display the cost of delivering the parcel or exit the system. This menu should be repeated each time after the user has chosen and completed an option until the user chooses to Exit. The user selects an option by entering the number next to it. If an invalid number is selected, the user is advised and shown the menu again to make another selection.
Main Menu
1. Setup Cost Per KM
2. Enter Parcel
3. Display Parcel Delivery Costs
4. Exit System
3) When the user selects the Setup Cost Per KM option, prompt the user to enter the cost (per KM) to transport a package sent 100KM or less. The user should then be prompted to enter the cost (per KM) to transport a package sent over 100KM. After each prompt, the system reads and saves the value from the user before proceeding. When both values have been entered, send a message to the user informing them of what has been set and then show the menu.
Main Menu
1. Setup Cost Per KM
2. Enter Parcel
3. Display Parcel Delivery Costs
4. Exit System 1
Enter how much it costs per km for a package to be sent 100KM or less: $ 0.59 Enter how much it costs per km for a package to be sent over 100KM: $ 0.86
The cost for a parcel to be sent 100km or less is $0.59 per km. The cost for a parcel to be sent more than 100km is $0.86 per km
Main Menu
1. Setup Cost Per KM
2. Enter Parcel
3. Display Parcel Delivery Costs
4. Exit System
Note: the green text is the user-entered data and may change each time.
4) When the user selects Enter Parcel, prompt the user to enter the receivers name, the weight of the parcel, if they want insurance and how far the parcel is to be sent. Once the user has entered these values, save them for later access, send a message to the user informing them of what has been set and then redisplay the menu.
Main Menu
1. Setup Cost Per KM
2. Enter Parcel
3. Display Parcel Delivery Costs
4. Exit System 2
Enter receivers name: Greg Enter weight of parcel: 100
Do you want insurance (Y or N)? Y
How far do you want to send the parcel (km)? 512
You have entered the following details: Receivers Name: Greg
Parcel Weight: 100.0 Insurance: true
KM to be sent: 512
Main Menu
1. Setup Cost Per KM
2. Enter Parcel
3. Display Parcel Delivery Costs
4. Exit System
5) When the user selects ‘Display Parcel Delivery Costs', display a calculation of the transportation, insurance and total costs. This uses the data provided in Steps 1 and 2. The following rules will help calculate the total cost:
- The amount of transport is calculated on the number of KM travelling required times the costs per km.
- If the user has asked for insurance, this should be calculated by multiplying the weight of the parcel by 0.53
- The total cost is the combination of the transport and insurance costs
- The transportation, insurance and total costs should be displayed to 2 decimal places
- After showing the calculations, the menu should be displayed
Main Menu
1. Setup Cost Per KM
2. Enter Parcel
3. Display Parcel Delivery Costs
4. Exit System 3
+++++ Calculating Costs +++++ Transportation Costs: 440.32
Insurance Costs: 53.0
Total Costs: 493.32
+++++++++++++++++++++++++++++
Main Menu
1. Setup Cost Per KM
2. Enter Parcel
3. Display Parcel Delivery Costs
4. Exit System
6) When the user selects Exit System, quit the program with a message to the user. The message should be unique
Main Menu
1. Setup Cost Per KM
2. Enter Parcel
3. Display Parcel Delivery Costs
4. Exit System 4
Thank you for using this calculator!
Standard Functionality:
7) Modularize the code, correctly using method calls and passing data between methods as parameters.
8) Ensure the code complies with coding standards. This includes
- Commenting the code so that it is clear what the code is doing and anything potentially unclear to future developers is explained. Hint: A well-documented algorithm/pseudocode/flowchart is an excellent starting point for this.
- Replace any "magic numbers" with constants or variables, as appropriate. All values that have consistent values throughout the program should be stored as constants.
- Indent the code and include white space as required to improve its readability.
- Ensure all variables and constants have clear names that reflect their purpose
- Comment the code
Advanced Functionality:
9) Enhance the ‘Display Parcel Delivery Costs' menu item so that it also displays when the parcel will arrive. The methods and attributes needed to complete this task are not explicitly taught in class. This task requires you to apply what you have learnt about reading the Java API to find a way to implement the functionality. The delivery date is calculated using the following rules
- It takes 1 day to travel 10 KM
- The current date/time should be used as the send date/time
- The expected due date/time is displayed to the user
Main Menu
1. Setup Cost Per KM
2. Enter Parcel
3. Display Parcel Delivery Costs
4. Exit System 3
+++++ Calculating Costs +++++ Transportation Costs: 440.32
Insurance Costs: 53.0
Total Costs: 493.32
The parcel will arrive at: Fri Dec 22 09:46:39 AEDT 2017
+++++++++++++++++++++++++++++
Main Menu
1. Setup Cost Per KM
2. Enter Parcel
3. Display Parcel Delivery Costs
4. Exit System
Stage 3: Testing
Using a copy of the test cases developed in Stage 1: Design, test the program you have developed in
Stage 2: Program Development. Document your results, including both failed and successful tests.
Note: Please do not leave out any failed tests. If your testing highlights that your program has not worked correctly, then the failed tests help to demonstrate that you have been testing your program properly.
To show that you have tested your program, include small (but readable) screen captures in your Actual Results as well as any explanatory comments. Microsoft Windows includes a Snipping Tool that is useful for taking captures of the relevant parts of the screen.
You may test your program in phases if you wish. Stage 2: Program Development provides three separate groups of functionality in the requirements, working from the minimal level of requirements through to more advanced concepts. Each of these groups can be tested individually.
Base Functionality:
This phase requires you to check that the base functions (displaying a welcome message when the program starts, showing a menu of options until the user chooses to exit, and Options 1, 2 and 3) have been implemented.
Standard Functionality:
This section does not include any functionality beyond that of the base functionality, however, if you needed to make changes to your code to implement modularization and coding standards, testing is required to ensure that the code still works properly once these changes have been made. Small changes made to code can quite often result in bugs so retesting is important to confirm the correct behaviour has been retained.
Advanced Functionality:
This phase requires testing the code that calculates and displays how long it will take for the parcel to arrive.