You want to write a program that will generate accurate shipping charges for a local grocery store. The shipping charges for the store are as follows: Weight of Package (in pounds)                Rate per mile Shipped  5 Lbs or less                                                         $0.20 Over 5 Lbs but no more than 8 Lbs                       $0.35 Over 8 Lbs but not more than 16 Lbs                    $0.45 Over 16 Lbs                                                          $0.50 Do NOT use global variables for this exercise. Write a function in a program that asks for the weight of a package in pounds and the distance it is to be shipped. These two arguments are to be passed into the funciton by REFERENCE. Using that data, write a second function (called by the main program) that calculates the shipping charge and returns it to the main program and displays the value inside the main program. For the second function, pass the two values (weight and distance) into the function as arguments. In the second function, if the shipping distance the user provided earlier is a distance greater than 20 miles, there will be an additional "Extended Distance" charge of $50 added to the order. For example, if an item weighing 21 pounds is shipped 25 miles, the total cost will be $62.50, calculated by the formula: ((25 miles * 0.50) + 50). Output to the user might read: A package weighing 21 pounds being shipped 25 miles will cost $62.50, which includes an "extended" distance charge of $50. input validation: Do not accept any weights less than 1 pound, nor any distances less than 0 miles.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.3: Returning Multiple Value
Problem 6E
icon
Related questions
Question
  1. You want to write a program that will generate accurate shipping charges for a local grocery store. The shipping charges for the store are as follows:

    Weight of Package (in pounds)                Rate per mile Shipped 
    5 Lbs or less                                                         $0.20
    Over 5 Lbs but no more than 8 Lbs                       $0.35
    Over 8 Lbs but not more than 16 Lbs                    $0.45
    Over 16 Lbs                                                          $0.50

    Do NOT use global variables for this exercise.

    Write a function in a program that asks for the weight of a package in pounds and the distance it is to be shipped. These two arguments are to be passed into the funciton by REFERENCE.

    Using that data, write a second function (called by the main program) that calculates the shipping charge and returns it to the main program and displays the value inside the main program. For the second function, pass the two values (weight and distance) into the function as arguments. In the second function, if the shipping distance the user provided earlier is a distance greater than 20 miles, there will be an additional "Extended Distance" charge of $50 added to the order. For example, if an item weighing 21 pounds is shipped 25 miles, the total cost will be $62.50, calculated by the formula: ((25 miles * 0.50) + 50).

    Output to the user might read:

    A package weighing 21 pounds being shipped 25 miles will cost $62.50, which includes an "extended" distance charge of $50.

    input validation: Do not accept any weights less than 1 pound, nor any distances less than 0 miles.

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr