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.
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 1ml, or 0.5ml if the nitrate is equal to or less than 1.
Remember to add a comment before a subprogram or selection statement to explain its purpose.
calculate_dose so that it: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.
// Nitrate program
using System;
class Submission
{
---
// -------------------------
// Subprograms
// -------------------------
// Calculate the carbon dose
static double calculate_dose(double nitrate)
{
---
// Nitrate is more than 10 dose 3ml
if (nitrate > 10)
{
---
return 3;
---
}
---
// Nitrate is more than 2.5 dose 2ml
else if (nitrate > 2.5)
{
---
return 2;
---
}
---
// Nitrate is more than 1 dose 1ml
else if (nitrate > 1)
{
---
return 1;
---
}
---
// Dose 0.5ml in all other cases
else
{
---
return 0.5;
---
}
---
}
---
// -------------------------
// Main program
// -------------------------
public static void Main(string[] args)
{
---
Console.WriteLine("Enter the nitrate level from the test:");
double nitrate = Convert.ToDouble(Console.ReadLine());
---
double carbon_dose = calculate_dose(nitrate);
---
Console.WriteLine($"For {nitrate} nitrate dose {carbon_dose} ml of carbon.");
---
}
---
}