Write a program ShippingCharges.cpp that asks for the weight of the package and the distance it is to be shipped, then displays the charges. For example: If weight = 5 kg and distance = 1600 miles, then the calculation is shipping rate = $2.20 and the distance rate factor is round-up of (1600 / 500 = 3.2), which is 4. Thus the shipping charge is $2.20 x 4 = $8.80 Input validation: Do not accept values of 0 or less for the weight of the package. Do not accept weights of more than 20 kg (this is the maximum weight the company will ship). Do not accept distances of less than 10 miles or more than 3,000 miles. These are the company's minimum and maximum shipping distances. Terminate program is invalid input detected.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 28PE
icon
Related questions
Question

Use relational and logical operators to make decisions using selection structures

The Fast Freight Shipping Company charges the following rates:
Weight of Package (in Kilograms)
Rate per 500 Miles Shipped
2 kg or less
$1.10
Over 2 kg but not more than 6 kg
$2.20
Over 6 kg but not more than 10 kg
$3.70
Over 10 kg but not more than 20 kg
$4.80
Write a program ShippingCharges.cpp that asks for the weight of the package and the
distance it is to be shipped, then displays the charges. For example:
If weight = 5 kg and distance = 1600 miles, then the calculation is shipping rate = $2.20 and the
distance rate factor is round-up of (1600 / 500 = 3.2), which is 4. Thus the shipping charge is
$2.20 x 4 = $8.80
Input validation: Do not accept values of 0 or less for the weight of the package. Do not accept
weights of more than 20 kg (this is the maximum weight the company will ship). Do not accept
distances of less than 10 miles or more than 3,000 miles. These are the company's minimum and
maximum shipping distances. Terminate program is invalid input detected.
Task 1 Sample Outputs:
Enter the weight of the package (20 Kg Max.): 25
The weight entered is out of acceptable range!
Enter the weight of the package (20 Kg Max.): 5
Enter the shipping distance in miles (>= 10 and <= 3000) : 3100
The distance entered is out of acceptable range!
Enter the weight of the package (20 Kg Max.) : 12
Enter the shipping distance in miles (>= 10 and <= 3000): 1220
The shipping charges: $14.40
Enter the weight of the package (20 Kg Max.): 6
Enter the shipping distance in miles (>= 10 and <= 3000): 2500
The shipping charges: $11.00
Transcribed Image Text:The Fast Freight Shipping Company charges the following rates: Weight of Package (in Kilograms) Rate per 500 Miles Shipped 2 kg or less $1.10 Over 2 kg but not more than 6 kg $2.20 Over 6 kg but not more than 10 kg $3.70 Over 10 kg but not more than 20 kg $4.80 Write a program ShippingCharges.cpp that asks for the weight of the package and the distance it is to be shipped, then displays the charges. For example: If weight = 5 kg and distance = 1600 miles, then the calculation is shipping rate = $2.20 and the distance rate factor is round-up of (1600 / 500 = 3.2), which is 4. Thus the shipping charge is $2.20 x 4 = $8.80 Input validation: Do not accept values of 0 or less for the weight of the package. Do not accept weights of more than 20 kg (this is the maximum weight the company will ship). Do not accept distances of less than 10 miles or more than 3,000 miles. These are the company's minimum and maximum shipping distances. Terminate program is invalid input detected. Task 1 Sample Outputs: Enter the weight of the package (20 Kg Max.): 25 The weight entered is out of acceptable range! Enter the weight of the package (20 Kg Max.): 5 Enter the shipping distance in miles (>= 10 and <= 3000) : 3100 The distance entered is out of acceptable range! Enter the weight of the package (20 Kg Max.) : 12 Enter the shipping distance in miles (>= 10 and <= 3000): 1220 The shipping charges: $14.40 Enter the weight of the package (20 Kg Max.): 6 Enter the shipping distance in miles (>= 10 and <= 3000): 2500 The shipping charges: $11.00
Expert Solution
Introduction

Use an if else structure to validate the values and then use if else if ladder to calculate amount

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
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++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT