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.

Nitrate

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.

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.
🆘 If you're really stuck, use this Parsons code sorting exercise Drag the code statements putting them into the correct order.