Question
Write a program that will accept as input a one-character service code (R for Regular, P for Priority, O for Overnight) followed by the weight
Write a program that will accept as input a one-character service code (R for Regular, P for Priority, O for Overnight) followed by the weight of the package. The program should then compute and print the appropriate charge for the customer.
For example, your program should output something like the following
>./a.out
>Please enter the service code and weight of the package: P 8.0
The service you chose is Priority service.
The weight of your package is 8.0 Kilograms.
The shipping charge for this package is $60.00.
The Fast Freight Company provides three kinds of shipping services for packages: regular, priority and overnight. They charge the following rates:
| Regular | Priority | Overnight |
<= 2 Kg | $1.00 per Kg | $3.50 per Kg | $11.50 per Kg |
> 2 Kg but <=6 Kg | $1.50 per Kg | $5.50 per Kg | $16.50 per Kg |
> 6 Kg but <=10 Kg | $2.00 per Kg | $7.50 per Kg | $21.50 per Kg |
> 10 Kg | $2.50 per Kg | $9.50 per Kg | $26.50 per Kg |
- The program MUST contain at least one if statement and at least one switch statement.
- For service codes other than R, P and O, your program should output an error message Error: Invalid service code and quit.
- The weight of the package may be a fractional number.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started