Assignment #2

Due: Tues, June 3

Objective

This assignment will involve practice with selection statements.

Task

You will write a program to compute shipping charges based on various criteria. Write your program in a file with the following filename:

Description

The Fast Freight Shipping Company charges the following rates:
Weight of Package (in Kilograms) Rate per 500 Miles Shipped
2 Kg or less$1.10
Over 2 Kg, up through 6 Kg$2.20
Over 6 Kg, up through 10 Kg$3.70
Over 10 Kg, up through 20 Kg$4.80

You will write a program that asks for the weight of the package and the distance it is to be shipped, and then you will display the charges. Here are the details:

Sample Runs

(user input is underlined, to distinguish it from output)

Sample run 1

Welcome to FFSC Shipping Calculator

Please enter the weight of the package, in Kg: 19.4 
Please enter the distance to be shipped (in miles): 2318

Package weight = 19.4 Kg
Shipping rate = $4.80 per 500 miles
Number of miles = 2318

Total shipping charges = $ 24.00

Goodbye

Sample run 2

Welcome to FFSC Shipping Calculator

Please enter the weight of the package, in Kg: 8.4
Please enter the distance to be shipped (in miles): 1340

Package weight = 8.4 Kg
Shipping rate = $3.70 per 500 miles
Number of miles = 1340

Total shipping charges = $ 11.10

Goodbye

Sample run 3 (error case)

Welcome to FFSC Shipping Calculator

Please enter the weight of the package, in Kg: -5
Invalid package weight. Program aborted

Sample run 4 (error case)

Welcome to FFSC Shipping Calculator

Please enter the weight of the package, in Kg: 21.8
Cannot accept packages over 20 Kg. Program aborted

Sample run 5 (error case)

Welcome to FFSC Shipping Calculator

Please enter the weight of the package, in Kg: 17.4
Please enter the distance to be shipped (in miles): -10
Shipping distance must be positive. Program aborted

Sample run 6 (error case)

Welcome to FFSC Shipping Calculator

Please enter the weight of the package, in Kg: 14.6
Please enter the distance to be shipped (in miles): 3010
Cannot ship more than 3000 miles. Program aborted.

General requirements


Submitting:

Use the Assignment 2 submission link on Blackboard. Submit only your source code:
   Shipping.java