Assignment 4
Shipping Calculator
Goal: You will apply everything you have learned so far about variables, data types, operators, and selection to write a simple but nonetheless real-world application.
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.
You need to
- Create an IPO.
(10 points)
- Create one more non-trivial (all zeros) test case.
(4 points)
- Write and debug the code that solves the problem.
(65 points)
- Take screen shots of running the program six different times. Use the five test cases given above and one more test case that you have created. (Total six test cases -12 points)
- Include programmer name, date and brief problem description at the beginning of the code.
(4 points)
- Include meaningful comments wherever necessary.
(5 points)
Hints: This program does not need any loops. We are only up to video segment 7. It will calculate one shipping charge and stop.
Deliverables: Submit only one Word document.
- Include your IPO at the top.
- Then, copy and paste your code into the Word document.
- State your additional test case.
- Then use ‘Snipping tool’ to take the screen shots of the 6 outputs. (Google it if you do not know how to use it.)
- Submit the Word document with solutions to all parts of the assignment by the deadline.