In: Computer Science
The Fast Freight Shipping Company charges the followingrates:
Weight of Package(kilograms) Rate per 500 miles shipped
2 kg orless $1.10
Over 2 kg but not more than6kg $2.20
Over 6 kg but not more than 10kg $3.70
Over 10 kg but not more than 20kg $4.80
Write a program that asks for the weight of the package andthe distance it is to be shipped, and then displays thecharges.
Input Validation: Do not accept values of 0 or less for theweight of the package. Do not accept weights of more than 20 kg. Do not accept distances of less than 10 miles or more than 3,000miles.
Can someone do this in PYTHON please!
Sample Outputs
3kg and 501 miles = $4.40
7kg and 501 miles = $7.40
11 kg and 501 miles = $9.60
I don't know how to get these outputs
I JUST NEED THE IF/ELIF STATEMENTS IN ORDER TO GE THESE OUTPUTS, I ALREADY HAVE THE RESTRICTIONS IN CODE
weight=int(input("enter weight")) while weight>=21 or weight<=0: print("weight must be greater than 0 but less than 20 ") weight=int(input("enter weight")) shippingDistance=int(input("Enter Shipping Distance")) while shippingDistance >= 3001 or shippingDistance <= 9: print("Distance must be between 10 and 3000 miles") shippingDistance=int(input("Enter Shipping Distance"))
rated_distance = 500; # miles
weight = float(input('Enter weight (kg): '))
if weight<=0 or weight>20:
print('weight must be greater than 0 and at most 20 kg')
else:
distance = float(input('Enter distance (miles): '))
if distance<10 or distance>3000:
print('distance cannot be less than 10 or greater than 3000
miles')
else:
#
# find d representing the multiples of rated_distance (including
the excess)
d = int(distance/rated_distance) + int((distance -
int(distance/rated_distance)*rated_distance)>0)
#
# compute the charges
if weight<=2:
charges = d * 1.10
elif weight>2 and weight<=6:
charges = d * 2.20
elif weight>6 and weight<=10:
charges = d * 3.70
elif weight>10 and weight<=20:
charges = d * 4.80
#
print(str(weight),'kg and ', str(distance), ' miles = $',
str(charges))
------------------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,
IF YOU'RE SATISFIED, GIVE A THUMBS UP
~yc~