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

  1. The program MUST contain at least one if statement and at least one switch statement.
  2. For service codes other than R, P and O, your program should output an error message Error: Invalid service code and quit.
  3. The weight of the package may be a fractional number.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!