Question: Global Courier Services will ship your package based on how much it weighs and how far you are sending the package. Packages above 50 pounds
Global Courier Services will ship your package based on how much it weighs and how far you are sending the package. Packages above 50 pounds will not be shipped. You need to write a program in C that calculates the shipping charge.
The shipping rates are based on per 500 miles shipped. They are not pro-rated, i.e., 600 miles is the same rate as 900 miles or 1000 miles.
Here are the shipping charges -
Package Weight Rate per 500 miles shipped
- Less than or equal to 10 pounds $3.00
- More than 10 pounds but less than or equal to 50 pounds $5.00
If the shipping distance is more than 1000 miles, there is an additional charge of $10 per package shipped.
Here are some test cases.
Test Case 1:
Input Data:
Weight: 1.5 pounds
Miles: 200 miles (This is one 500 mile segment.)
Expected results:
Your shipping charge is $3.00
Test Case 2:
Input Data:
Weight: 5.6 pounds
Miles: 1200 miles (This is three 500 mile segments.)
Expected results:
Your shipping charge is $19.00
Test Case 3:
Input Data:
Weight: 11.0 pounds
Miles: 2000 miles (This is four 500 mile segments.)
Expected results:
Your shipping charge is $30.00
Test Case 4:
Input Data:
Weight: 38 pounds
Miles: 9600 miles (This is twenty 500 mile segments.)
Expected results:
Your shipping charge is $110.00
Test Case 5:
Weight: 55 pounds
Miles: 345 miles
Expected results:
Sorry, we only ship packages of 50 pounds or less.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
