internal class Program { private static void Main(string[] args) { //VARIABLES const int CarrotLength = 8; //Constant to store the length of a patch for an individual carrot const int CarrotWidth = 8; //Constant to store the width of a patch for an individual carrot int NumCarrots = 0; //Stores the number of carrots int VegetableBedLength = 0; //Stores the length of the user's vegetable bed int VegetableBedWidth = 0; //Stores the width of the user's vegetable bed //Length of vegetable bed Console.WriteLine("Please enter the length of your vegetable bed (to the closest cm)"); VegetableBedLength = Convert.ToInt32(Console.ReadLine()); //Get user input Console.WriteLine(" "); //Range check - Ensures that a number greater than 0 is entered do { if (VegetableBedLength == 0) { Console.WriteLine("Error: Invalid input"); Console.WriteLine(" "); Console.WriteLine("Please enter the length of your vegetable bed (to the closest cm)"); VegetableBedLength = Convert.ToInt32(Console.ReadLine()); //Get user input Console.WriteLine(" "); } } while (VegetableBedLength == 0); //Width of vegetable bed Console.WriteLine("Please enter the width of your vegetable bed (to the closest cm)"); VegetableBedWidth = Convert.ToInt32(Console.ReadLine()); //Get user input Console.WriteLine(" "); //Range check -Ensures that a number greater than 0 is entered do { if (VegetableBedWidth == 0) { Console.WriteLine("Error: Invalid input"); Console.WriteLine(" "); Console.WriteLine("Please enter the length of your vegetable bed (to the closest cm)"); VegetableBedWidth = Convert.ToInt32(Console.ReadLine()); //Get user input Console.WriteLine(" "); } } while (VegetableBedWidth == 0); //While loop to calculate how many carrots can be grown do { if (CarrotLength <= VegetableBedLength || CarrotWidth <= VegetableBedWidth) { VegetableBedLength = VegetableBedLength - CarrotLength; VegetableBedWidth = VegetableBedWidth - CarrotWidth; NumCarrots += 1; } } while (CarrotLength <= VegetableBedLength || CarrotWidth <= VegetableBedWidth); NumCarrots = NumCarrots * NumCarrots; //Calculates how many carrots can be grown for the area Console.WriteLine("You can grow " + NumCarrots + " carrots in your vegetable bed"); //Output how many carrots can be grown Console.WriteLine(" "); Console.WriteLine("Press enter to exit the program"); } }