Question

In: Computer Science

The Fast Freight Shipping Company charges the followingrates: Weight of Package(kilograms)         Rate per 500 miles shipped 2...

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"))

Solutions

Expert Solution

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~


Related Solutions

Customers arrive at the drive-up window of a fast-food restaurant at a rate of 2 per...
Customers arrive at the drive-up window of a fast-food restaurant at a rate of 2 per minute during the lunch hour What is the probability that the next customer will arrive within 1 minute? What is the probability that the next customer will arrive after 0.5 minutes? What is the probability that the next customer will arrive between 45 seconds and 1.5 minutes?
Customers arrive at a​ drive-up window of a​ fast-food restaurant at a rate of 2 per...
Customers arrive at a​ drive-up window of a​ fast-food restaurant at a rate of 2 per minute during lunch hour. a. What is the probability that the next customer will arrive within 2 minutes​? b. What is the probability that the next customer will arrive within 3 ​minutes? c. During the dinner time​ period, the arrival rate is 1 per minute. What are your answers to a and b for this​ period?
The Dash Cell Phone Company charges customers a basic rate of $5 per month to send...
The Dash Cell Phone Company charges customers a basic rate of $5 per month to send text messages. Additional rates are as follows: The first 100 messages per month, regardless of message length, are included in the basic bill. An additional three cents are charged for each text message after the 100th message, up to and including 300 messages. An additional two cents are charged for each text message after the 300th message. Federal, state, and local taxes add a...
Assume that a company just paid a dividend of $2 per share. The expected growth rate...
Assume that a company just paid a dividend of $2 per share. The expected growth rate in the dividend is a constant 10%. If your required rate of return for the stock is 15%, what is the value of the stock to you today?
A company just paid a $2 dividend per share. The dividend growth rate is expected to...
A company just paid a $2 dividend per share. The dividend growth rate is expected to be 10% for each of the next 2 years, after which dividends are expected to grow at a rate of 3% forever. If the company’s required return (rs) is 11%, what is its current stock price?
Japan Company produces lamps that require 2 standard hours per unit at a standard hourly rate...
Japan Company produces lamps that require 2 standard hours per unit at a standard hourly rate of $17.20 per hour. Production of 5,500 units required 10,780 hours at an hourly rate of $16.70 per hour. What is the direct labor (a) rate variance, (b) time variance, and (c) total cost variance? Enter favorable variances as negative numbers. a. Direct labor rate variance $ Unfavorable b. Direct labor time variance $ Unfavorable c. Total direct labor cost variance $ Unfavorable
A company currently pays a dividend of $3.6 per share (D0 = $3.6). It is estimated that the company's dividend will grow at a rate of 25% per year for the next 2 years
A company currently pays a dividend of $3.6 per share (D0 = $3.6). It is estimated that the company's dividend will grow at a rate of 25% per year for the next 2 years, and then at a constant rate of 8% thereafter. The company's stock has a beta of 1.1, the risk-free rate is 9.5%, and the market risk premium is 4.5%. What is your estimate of the stock's current price? Do not round intermediate calculations. Round your answer...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT