Nitrate

Nitrate

Reducing nitrate with carbon dosing in a fish tank.

When keeping fish, one of the goals to reduce algae is to keep nitrates to a minimum. One way of doing this is to dose a carbon source which nitrifying bacteria within an aquarium consume together with nitrates. The carbon source must be dosed very precisely.

Make


Write a program that outputs how much carbon to dose from the nitrate. Greater than 10 is 3ml, greater than 2.5 is 2ml, greater than 1 is ml, or 0.5ml if the nitrate is equal to or less than 1.

Use this boilerplate code as a starting point:

Success Criteria

Remember to add a comment before a subprogram or selection statement to explain its purpose.

Complete the subprogram called `calculate_dose` so that it:

  1. Calculates the carbon dose as 3ml if nitrate is greater than 10.
  2. Calculates the carbon dose as 2ml if nitrate is greater than 2.5.
  3. Calculates the carbon dose as 1ml if nitrate is greater than 1.
  4. Calculates the carbon dose as 0.5ml if nitrate is 1 or lower.
  5. Returns the carbon dose.

Complete the `main program` so that:

  1. The user can input the nitrate level as a decimal number.
  2. The correct carbon dose is output.

Typical inputs and outputs from the program would be:

Enter the nitrate level from the test: 25

For 25.0 nitrate dose 3 ml of carbon.


Enter the nitrate level from the test: 6

For 6.0 nitrate dose 2 ml of carbon.


Enter the nitrate level from the test: 1.25

For 1.25 nitrate dose 1 ml of carbon.

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 nitrate level from the test: 50

For 50.0 nitrate dose 3 ml of carbon.

Enter the nitrate level from the test: 7.25

For 7.25 nitrate dose 2 ml of carbon.

Enter the nitrate level from the test: 2

For 2.0 nitrate dose 1 ml of carbon.

Enter the nitrate level from the test: 0.5

For 0.5 nitrate dose 0.5 ml of carbon.

Check that you have:

  • Used comments within the code to describe the purpose of subprograms and conditions.
  • Used meaningful identifier names. That means the names of subprograms and variables indicate what they are for.

Registered in England and Wales: 10442992

VAT Number: 290 9845 58

Telephone: 01452 947500

Email: admin@craigndave.co.uk

Craig'n'Dave logo

Craig 'n' Dave

Bett Awards 2024 Finalist