Scenario : You want to calculate how many pounds of fertilizer you will need to
ID: 3795822 • Letter: S
Question
Scenario:
You want to calculate how many pounds of fertilizer you will need to buy to supply 1.0 pounds of Nitrogen per 1000 square feet to your lawn. The first number of the three number entries on the fertilizer bag represents what percentage of the fertilizer is Nitrogen. (For example a 20-10-10 fertilizer has 20% Nitrogen). All in C#
Inputs:
1) The length of your lawn in feet
2) The width of your lawn in feet
3) The percentage of Nitrogen in the fertilizer you intend to use
Processing:
1. Calculate the number of square feet in your lawn
2. Divide the number of square feed by 1000 to get the number of pounds of Nitrogen you need
3. Convert the percentage number from the input to a decimal number by dividing by 100.
4. Calculate the number of pounds of fertilizer needed by dividing the number of pounds of Nitrogen you need by the percentage of Nitrogen in the fertilizer.
Output:
Display a nicely worded message that indicates how many pounds of fertilizer you will need with 2 decimal places.
Explanation / Answer
using System;
public class Test
{
public static void Main()
{
//input length and width of lawn
Console.WriteLine("Enter the length of your lawn in feet");
double length = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter the width of your lawn in feet");
double width = Convert.ToDouble(Console.ReadLine());
//input % of nitrogen in the fertilizer
Console.WriteLine("Enter the percentage of Nitrogen in the fertilizer you intend to use");
double nitrogenBag = Convert.ToDouble(Console.ReadLine());
double area = length * width; //calculate area of lawn
double nitrogenNeed = area /1000; // nitrogen needed per 1000 square
double nitrogenBagPer = nitrogenBag/100; //calculate nitrogen percentage
double fertilizer = nitrogenNeed/nitrogenBagPer;// fertilizer needed in pounds
Console.WriteLine("The pounds of fertilizer you will need to buy to supply 1.0 pounds of Nitrogen per 1000 square feet to your lawn : {0:F2}",fertilizer);
}
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.