Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 300 Weeks Ago, 2 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Management Posted 10 Feb 2018 My Price 10.00

Shipping.java

Task

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

A????1    Shipping.java

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:

A????1      First, ask for the weight of the package (in kilograms). The user can enter this as a decimal number, so use type double. Values of 0 or less are invalid (i.e. a package has to weigh something). Do not accept weights of more than 20 Kg either, as this is the maximum weight the company will ship).

A????1      If the user enters an invalid choice, print an appropriate error message and abort the program. (See sample outputs for error messages)

A????1    Now ask the user to enter the distance to ship the package (in miles). This will

be entered as an integer. 0 miles or less is considered invalid (must be a

positive distance to ship). Also, do not accept distances of more than 3000 miles -- consider 3000 miles to be the company's maximum shipping distance

A????1      If the user enters an invalid choice, print an appropriate error message and abort the program. (See sample outputs for error messages)

A????1    For a valid weight and distance, compute the shipping charges according to the

chart above, noting that "rate per 500 miles shipped" means that anything up to

500 miles is at the 500 mile rate, anything above 500 up to 1000 miles is at the

1000 mile rate, and so on.

Example: shipping a 8 Kg package 1300 miles would be at the $3.70 per 500 miles rate, and since it's 1300 miles, it would be $11.10 (i.e. $3.70 times 3)

A????1    Print out the following results:

o The package weight (default format), in kilograms

o The shipping rate for this package, to 2 decimal places, (money format)

o The number of miles chosen

o The calculated shipping cost, to 2 decimal places (money format)

A????1      See the Sample Runs below for expected output messages and numerical output formats

A????1      Also note: The System library has a method called exit(), which will cause a program to terminate immediately. It requires a parameter -- usually it is

sufficient to just pass in the value 0

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, Please enter the distance to be shipped

in Kg: 19.4 (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, Please enter the distance to be shipped

in Kg: 8.4 (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

A????1    Use the Scanner class for input

Answers

(5)
Status NEW Posted 10 Feb 2018 09:02 PM My Price 10.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on-----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be-----------

Not Rated(0)