Tony's travel tracker

Tony runs a "fishing" boat in the Mediterranean. He doesn't catch fish, though. He transports high-value cargo, discreetly. Write a program to help Tony estimate his costs for a trip. Download the attached worksheet to save time.

The worksheet starts like this:

Start

There are three inputs: trip length (km), cargo weight (kg), and heat level. Heat level is the amount of attention the cargo would attract from local authorities, if it was discovered. Heat is either high, medium, or low.

Validate the input, using these rules.

  • Length and cargo must be numbers greater than zero.
  • Length cannot be more than 1,000.
  • Weight cannot be more than 2,000.
  • Heat must be H, M, or L. Case doesn't matter. Extra spaces don't matter.

If input is not valid, show an appropriate error message. For example:

Error

Costs are:

  • Fuel.
  • "Crew" to protect the cargo.
  • "Gifts" to local officials to, er, expedite shipping.
  • Overhead: an extra charge Tony throws in.

Fuel is €8 for each kilometer.

The other three depend on the heat level.

  • High: Crew costs €89 for each kg. Gifts are €4,000. Overhead is €44 for each kg, plus €31 for each km.
  • Medium: Crew costs €58 for each kg. Gifts are €2,000. Overhead is €25 for each kg, plus €19 for each km.
  • Low: Crew costs €38 for each kg (just Tony's cousin Stretchy Raoul). Gifts are €1,200. Overhead is €27 for each kg, plus €11 for each km.

Output these values, and the total. For example:

Output

Hint: Use longs or singles, not integers.

Upload your workbook.

(If you were logged in as a student, you could submit an exercise solution, and get some feedback.)

Referenced in: 
Attachments: