Test Case
1.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 Cost Per KM |
The user is prompted to enter the travel cost (per KM) for a package sent under 100KM….. |
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
Expected Result
• 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
CRICOS Provider No. 00103D Summer 2017-18 Assignment 1 Specifications Page 4 of 8
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
CRICOS Provider No. 00103D Summer 2017-18 Assignment 1 Specifications Page 5 of 8
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
CRICOS Provider No. 00103D Summer 2017-18 Assignment 1 Specifications Page 6 of 8
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.
Submission
Your program code and testing documentation should be zipped into a single file and loaded into the
Assignment Box provided in Moodle by the due date and time.
Feedback
Assignments will be marked within 2 weeks of submission. Marks will be made available by the
lecturer
Plagiarism:
Plagiarism is the presentation of the expressed thought or work of another person as though it is one's
own without adequately acknowledging that person. You must not allow other students to copy your
work and must take care to safeguard against this happening. More information about the plagiarism
policy and procedure for the university can be found at http://federation.edu.au/students/learning-andstudy/online-help-with/plagiarism.
Test Case
1.Algorithm:
Step 1: Initialize the variable to store the data
Step 2: Display the Welcome message
Step 3: Display the Menu
Step 4: Get the menu option from the user
Step 5: If the User Selects Setup Cost Per KM option perform step 6 and 7 else move to Step 10
Step 6: Get the costs per km for a package to be sent for 100KM or less distance from the User
Step 7: Get the costs per km for a package to be sent for over 100KM distance from the User
Step 8: Display the details entered by the user
Step 9: Go to Step 3
Step 10: If the User Selects Enter Parcel option perform step 11 to 17 else move to Step 18
Step 11: Get the receiver name of the package from the User
Step 12: Get the weight of the package from the User
Step 13: Get whether the insurance is required for the package from the User
Step 14: Get the number of KMs the package wants to travel from the User
Step 15: Display the details entered by the user
Step 16: Compute the delivery date of the package
Step 17: Go to Step 3
Step 17: If the User Selects Display Parcel Delivery Costs option perform step 18 to 23 else move to Step 24
Step 18: Compute the transportation cost by multiplying the distance and its corresponding cost
Step 19: Determine the insurance cost if the insurance is required for the package
Step 20: Compute the total cost i.e. transportation cost + insurance cost
Step 21: Display the cost details
Step 22: Display the delivery date of the package
Step 23: Go to Step 3
Step 24: If the user select the Exit System option perform step 25 else go to step 27
Step 25: Display the Exit message to the user
Step 26: Terminate the program execution
Step 27: If the user enters none of the option; Display the message of invalid choice and Go to Step 3
2.Program:
package transportapplication;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
public class TransportApplication {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
// Display the header message
for(int i=0;i<40;i++) {
System.out.print("-+");
}
System.out.println();
for(int i=0;i<10;i++) {
System.out.print(" ");
}
System.out.println("FEDERATION UNIVERSITY AUSTRALIA - MT HELEN");
System.out.println("");
Expected Result
for(int i=0;i<10;i++) {
System.out.print(" ");
}
System.out.println("Christmas Parcel Delivery Calculator");
System.out.println();
System.out.println(" Developed by Arslan Ahmed, Student ID: 30338159 for ITECH1000 Summer 2017");
System.out.println();
for(int i=0;i<40;i++) {
System.out.print("-+");
}
System.out.println();
boolean loop=true;
// variable to store the data
float costLessThan100=0, costOver100=0;
String receiversName="";
float parcelWeight=0;
String insurenceRequired="";
int distance=0;
float INSURENCE_PARAMETER=(float) 0.53;
//date to store the current time
Date deliveryDate=new Date();
// format in which date should be displayed
DateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
while(loop)
{
//display the menu
displayMenu();
//get the choice from the user
int choice=sc.nextInt();
switch(choice)
{
case i:
// When Setup Cost Per KM is selected
System.out.print("Enter how much it costs per km for a package to be sent 100KM or less: $ ");
costLessThan100=sc.nextFloat();// receive costs per km of the package sent 100KM or less
System.out.print("Enter how much it costs per km for a package to be sent over 100KM: $ ");
costOver100=sc.nextFloat();// receive costs per km of the package sent over 100KM
System.out.println();
//display the cost of the package per km
System.out.println("The cost for a parcel to be sent 100km or less is $"+costLessThan100+" per km.");
System.out.println("The cost for a parcel to be sent more than 100km is $"+costOver100+" per km");
break;
case ii:
// When Enter Parcel is selected
System.out.print("Enter receivers name: ");
receiversName=sc.next();//receive the receivers name of the package
System.out.print("Enter weight of parcel: ");
parcelWeight=sc.nextFloat();//receive the weight of the package
System.out.print("Do you want insurance (Y or N)? ");
insurenceRequired =sc.next();//receive the insurance status of the package
System.out.print("How far do you want to send the parcel (km)? ");
distance=sc.nextInt();//receive the number of km the package must be sent
System.out.println();
//display the parcel package information
System.out.println("You have entered the following details:");
System.out.println("Receivers Name: "+ receiversName);
System.out.println("Parcel Weight: "+ parcelWeight );
System.out.println("Insurance: "+ (insurenceRequired.equals("Y")?"true":"false") );
System.out.println("KM to be sent: "+ distance);
//calculate the delivery date of the package from the distance
deliveryDate=getDeliveryDate(distance);
break;
case iii:
// when Display Parcel Delivery Costs is selected
System.out.println("ntt+++++ Calculating Costs +++++");
float transportationCost=0;
//calculate the transportationCost based on the distance the parcel requires to travel
if(distance<=100) {
transportationCost=distance*costLessThan100;
} else {
transportationCost=distance*costOver100;
}
float insurenceCost=0;
//calculate the insurence cost based on the insurence requirement of the package
if(insurenceRequired.equals("Y")) {
insurenceCost=parcelWeight*INSURENCE_PARAMETER;
}
// calculate the total cost of the package
float totalCost=transportationCost+insurenceCost;
// display the cost details
System.out.println("ttTransportation Costs: "+Math.round(transportationCost*100.0)/100.0);
System.out.println("ttInsurance Costs: "+ Math.round(insurenceCost*100.0)/100.0);
System.out.println("ttTotal Costs: "+Math.round(totalCost*100.0)/100.0);
System.out.println("nttThe parcel will arrive at: "+dateFormat.format(deliveryDate));
System.out.println("tt+++++++++++++++++++++++++++++");
break;
case iv:
// When Exit System is selected
System.out.println("nThank you for using this calculator!");
loop=false;//set loop to false to stop the loop
break;
default:
System.out.println("Invalid Choice- Please enter the correct choice");
break;
}
}
}
private static void displayMenu() {
System.out.println("nMain Menu");
System.out.println("1. Setup Cost Per KM");
System.out.println("2. Enter Parcel");
System.out.println("3. Display Parcel Delivery Costs");
System.out.println("4. Exit System ");
}
private static Date getDeliveryDate(int distance) {
/*
Compute the delivery date by considering it takes 1 day to travel 10Km
*/
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, distance/10);
return calendar.getTime();
}
}
Output:
3.Testing Base Requirement:
Test Case |
Expected Result |
Actual Result |
The user selects the menu option: Setup Cost Per KM |
The user is prompted to enter the travel cost (per KM) for a package sent under 100KM and sent over 100KM |
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 user selects the menu option: Enter Parcel |
The user is prompted to enter the receivers name, the weight of the parcel, if they want insurance and how far the parcel is to be sent |
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 |
The user selects the menu option: Display Parcel Delivery Costs |
Displays calculation of the transportation, insurance and total costs |
Transportation Costs: 440.32 Insurance Costs: 53.0 Total Costs: 493.32 |
The user selects the menu option: Exit System |
Quit the program with a message to the user |
The program terminates with the message Thank you for using this calculator! |
The user selects the menu option: Not of the above choice |
Displays the message Invalid Choice- Please enter the correct choice |
Testing Standard Requirement:
Test Case |
Expected Result |
Actual Result |
Modularity |
Modularize the code |
The code is modularized with two function displayMenu() and getDeliveryDate() |
Comment |
The code is commented |
|
Adding Magic Numbers |
float INSURENCE_PARAMETER=(float) 0.53; |
Testing Advance Requirement:
Test Case |
Expected Result |
Actual Result |
The user selects the menu option: Display Parcel Delivery Costs |
Displays when the parcel will arrive |
Transportation Costs: 440.32 Insurance Costs: 53.0 Total Costs: 493.32 The parcel will arrive at: Sat Feb 24 19:30:26 EST 2018 |
To export a reference to this article please select a referencing stye below:
My Assignment Help. (2020). Transport Application - Christmas Parcel Delivery Essay.. Retrieved from https://myassignmenthelp.com/free-samples/itech1000-programming-in-java.
"Transport Application - Christmas Parcel Delivery Essay.." My Assignment Help, 2020, https://myassignmenthelp.com/free-samples/itech1000-programming-in-java.
My Assignment Help (2020) Transport Application - Christmas Parcel Delivery Essay. [Online]. Available from: https://myassignmenthelp.com/free-samples/itech1000-programming-in-java
[Accessed 09 January 2025].
My Assignment Help. 'Transport Application - Christmas Parcel Delivery Essay.' (My Assignment Help, 2020) <https://myassignmenthelp.com/free-samples/itech1000-programming-in-java> accessed 09 January 2025.
My Assignment Help. Transport Application - Christmas Parcel Delivery Essay. [Internet]. My Assignment Help. 2020 [cited 09 January 2025]. Available from: https://myassignmenthelp.com/free-samples/itech1000-programming-in-java.