File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1
1
# Shipping Cost Calculator
2
2
3
- ## Input package weight and shipping rate
3
+ ## Input package weight, volume dimensions, and shipping rate
4
4
weight = float (input ("Enter the package weight in kilograms: " ))
5
+ length = float (input ("Enter the package length in centimeters: " ))
6
+ width = float (input ("Enter the package width in centimeters: " ))
7
+ height = float (input ("Enter the package height in centimeters: " ))
5
8
rate = float (input ("Enter the shipping rate per kilogram: " ))
6
9
10
+ ## Calculate volumetric weight
11
+ volumetric_weight = (length * width * height ) / 5000
12
+
13
+ ## Choose the greater between actual and volumetric weight
14
+ chargeable_weight = max (weight , volumetric_weight )
15
+
7
16
## Calculate shipping cost
8
- shipping_cost = weight * rate
17
+ shipping_cost = chargeable_weight * rate
9
18
10
19
## Display the result
11
- print (f"Shipping Cost: { shipping_cost } USD" )
12
-
20
+ print (f"Shipping Cost: { shipping_cost :.2f} USD (based on { chargeable_weight :.2f} kg)" )
You can’t perform that action at this time.
0 commit comments