This has to be in C++ 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.
This has to be in C++
-
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.50Do 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.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images