Fish tank volume

Fish tank volume

Calculating the volume of water needed to fill a fish tank.

Supplements are often added to an aquarium to replace minerals, fertilisers or for medication. Knowing the correct volume of water in the tank is important so you know how much to dose.

Make


Write a program that calculates the volume of a fish tank in litres and imperial gallons from the length, height and depth in centimeters.

Use this boilerplate code as a starting point:

Success Criteria

Remember to add a comment before a subprogram to explain its purpose.

Complete the subprogram called `volume` so that:

  1. It returns the volume of water calculated as (length * width * height) / 1000.

Complete the subprogram called `litres_to_gallons` so that:

  1. It returns gallons as litres / 4.546.

Complete the `main program` so that:

  1. It allows the user to input the length, width and height of the fish tank in centimeters as integers.
  2. It calculates the litres and gallons using the subprograms.

Typical inputs and outputs from the program would be:

Enter the length of the tank in cm: 60

Enter the height of the tank in cm: 30

Enter the depth of the tank in cm: 24

A 60 x 30 x 24 cm tank is 43.2 litres and 9.50285965684118 imperial gallons.

Knowledge Organiser

Use these resources as a reference to help you meet the success criteria.

Programming guide:

Evaluate


Run the unit tests below to check that your program has met the success criteria.

Enter the length of the tank in cm: 36

Enter the height of the tank in cm: 24

Enter the depth of the tank in cm: 24

A 36 x 24 x 24 cm tank is 20.736 litres and 4.561372635283766 imperial gallons.

Enter the length of the tank in cm: 40

Enter the height of the tank in cm: 40

Enter the depth of the tank in cm: 40

A 40 x 40 x 40 cm tank is 64.0 litres and 14.078310602727672 imperial gallons.

Check that you have used comments within the code to describe the purpose of subprograms.