The DuPage Freight Shipping Company charges the following rates: Weight of Package Rate per Pound 2 pounds or less $1.10 Over 2 pounds, but not more than 6 pounds $2.20 Over 6 pounds, but not more than 10 pounds $3.70 Over 10 pounds $3.80 Design a program that does the following: asks the user to enter the weight of a package and displays the shipping charges. 1. Prompt the user for the weight of a package 2. Determines the rate per pound in a getRate module 3. Calculates and displays the total shipping charge in a getTotal module Hint - you may want to use a global variable for this! Please submit three things:

Answers

Answer 1

Answer:

The program in Python is as follows:

def getRate(weight):

   if weight<=2.0:

       rate = 1.10

   elif weight>2 and weight<=6:

       rate = 2.20

   elif weight>6 and weight<=10:

       rate = 3.70

   else:

       rate = 3.80

   return rate

def getTotal(weight,rate):

   total = weight * rate

   print("Total: ",total)

weight = float(input("Weight: "))

rate = getRate(weight)

getTotal(weight,rate)

Explanation:

This defines the getRate function

def getRate(weight):

The following if conditions determine the corresponding rate based on the value of weight passed to the function

   if weight<=2.0:

       rate = 1.10

   elif weight>2 and weight<=6:

       rate = 2.20

   elif weight>6 and weight<=10:

       rate = 3.70

   else:

       rate = 3.80

This returns the rate back to the main method

   return rate

The getTotal module begins here

def getTotal(weight,rate):

This calculates the total charges

   total = weight * rate

This prints the calculated total

   print("Total: ",total)

The main begins here

This gets input for weight

weight = float(input("Weight: "))

This gets the rate from the getRate function

rate = getRate(weight)

This passes values to the getTotal function

getTotal(weight,rate)


Related Questions

Determine whether the phrase below is a sentence or a fragment.

While we were in Greece, we ate a lot of feta cheese.
a.
Sentence
b.
Fragment

Answers

sentence.


i believe it is sentence
Other Questions
Lily bought a pair of gloves and a shirt.The gloves cost 4She sold the gloves and the shirt for a total of 48She made 100% profit on the cost of the gloves.20% profit on the total cost.Work out her percentage profit on the cost of the skirt.Answer 1 decimal place. 4. A bullet of mass 30 g is fired from a rifle of mass 5kg at a speed of 259m/s.a) What is the momentum of the rifle just after the bullet is fired?b) What is the recoil velocity of the rifle? what a beautiful scene it exclamatory mark or not plese give me a answer Which factor most contributed to Hernn Corts's victory over the AztecEmpire?A. Aztec leaders believed the Spanish were gods and refused toattack their troops.B. Spanish explorers brought diseases that devastated the AztecpopulationC. The Spanish military was substantially larger than the Aztecdefense forcesO D. The Aztec military relied on slave soldiers who sided with theSpanish In the dihybrid cross, of the parents had black fur and black eyes.The offspring . 6. Don Juan compro un terreno con las dimensiones que se muestran en la figura el cual se va acondicionar para realizar eventos sociales, por lo que desea instalar csped en la region sombreada. Cuantos metros cuadrados de csped requiere? Considera rt=3.14 16 m O 50 24 m2 0 205 76 m2 256 00 m2 0 5504 m2 Complete the following matching questions. Question Se sirve la comida en ____. Se pone la comida en ____. Los asistentes de vuelo vienen en el pasillo con las comidas y bebidas en Se abrocha ____ antes del despegue y aterrizaje. Se pone ____ del asiento en posicin vertical durante el despegue y el aterrizaje.All Answer ChoicesA. la bandejaB. la mesitaC. el carritoD. el cinturn de seguridadE. el respaldo Help! please don't just steal my pointss PLEASE ANSWER QUICK!!! 30 POINTSThe figure has angle measures as shown.A19x - 1526x + 20D9x + 25CBWhat is the measure of ZABD?O 150O 120O 70O 30 Recall the creative calligraphy case we discussed in class. Suppose you have received a rush order of 55 invitations that have to be created in the next (four hour) work session. What is the most time You (i.e. not Susie) can spend writing on the card and envelope for each invitation and still fill the order Conditional Statement: if p then q The converse form of a conditional statement is when: O p and q are switched, and both negated. p and the q are switched. Neither p or q is negated. O p and q are both negated. Neither p or q are swithced. a concrete has a height of 5m and has unit area 3m supports a mass of 30000kg. Determine the stress, strain and change in height Mathematics can help me with Describe the preparation of oxy carbon of halogen find the slope of a line perpendicular to the line below. y=2x+4 The side lengths of a triangle are 5, 8, and 12. Is this a right triangle? give the answer of very fast Exercise 4-11 Computing net sales for multiple-step income statement LO P4 A company reports the following sales-related information. Sales, gross $ 245,000 Sales returns and allowances $ 20,000 Sales discounts 4,900 Sales salaries expense 10,900 Prepare the net sales portion only of this companys multiple-step income statement. The expenditures and receipts below are related to land, land improvements, and buildings acquired for use in a business enterprise. The receipts are enclosed in parentheses.(a) Money borrowed to pay building contractor (signed a note) $(289,100 )(b) Payment for construction from note proceeds 289,100(c) Cost of land fill and clearing 11,860(d) Delinquent real estate taxes on property assumed by purchaser 7,990(e) Premium on 6-month insurance policy during construction 9,480(f) Refund of 1-month insurance premium because construction completed early (1,580 )(g) Architects fee on building 26,400(h) Cost of real estate purchased as a plant site (land $202,900 and building $56,600) 259,500(i) Commission fee paid to real estate agency 9,690(j) Installation of fences around property 4,140(k) Cost of razing and removing building 10,530(l) Proceeds from salvage of demolished building (4,690 )(m) Interest paid during construction on money borrowed for construction 12,230(n) Cost of parking lots and driveways 17,750(o) Cost of trees and shrubbery planted (permanent in nature) 13,350(p) Excavation costs for new building 3,290Identify each item by letter and list the items in columnar form, using the headings shown below. All receipt amounts should be reported in parentheses. For any amounts entered in the Other Accounts column, also indicate the account title. (Enter receipt amounts using either a negative sign preceding the number e.g. -45 or parentheses e.g. (45). If no entry is required in other accounts, select "No Entry" for the account titles.)Item Land LandImprovements Building Other Accounts(a) $$$$(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)