Hello, I have run into an issue where my output for shipping charge needs to be Real
Use local named constants not global
Also the package weight needs to be times the rate PER pound, is what I have correct?

rate1= 1.1
rate2= 2.2
rate3= 3.7
rate4= 3.8

def main():
   packageWeight = float(input( "What is the weight of the package?"))
   shipping_Weight(packageWeight)

def shipping_Weight(packageWeight):
    if packageWeight <= 2:
       Weight = rate1 * packageWeight
       print ("The total shipping charge is $: " , Weight)

        elif packageWeight <= 6:
            Weight = rate2 * packageWeight
            print ("The total shipping charge is $: " , Weight)

        elif packageWeight <= 10:
            Weight = rate3 * packageWeight
            print ("The total shipping charge is $: " , Weight)

        elif packageWeight > 10:
            Weight = rate4 * packageWeight
            print ("The total shipping charge is $: " , Weight)

main()

Recommended Answers

All 2 Replies

I have a question. Why are your rate1 to rate4 the same numbers as I see in a 2010 discussion at
https://www.dreamincode.net/forums/topic/196758-java-shipping-program/ ?

It would be incredibly coincidental if these were the same. If you are seeking homework help, just say so and share where we can find the assignment and remember that no one will write your homework for you. But you can get help on errors and more.

You can also add destination value to your shipping charge calculation to make your program more efficient.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.