Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions