public static int totalNumberOfPets;
public static int sumOfAllPetAges;
System.Console.WriteLine("How many pets do you have?");
int numberofpets = int.Parse(System.Console.ReadLine());
Pet[] yourPet = new Pet[numberofpets];
for (int i=0; i<numberofpets; i++)
System.Console.WriteLine("What is the name of your pet");
yourPet[i].name = System.Console.ReadLine();
System.Console.WriteLine("What is the breed of your pet");
yourPet[i].breed = System.Console.ReadLine();
System.Console.WriteLine("What is the age of your pet");
yourPet[i].age = int.Parse(Console.ReadLine());
Pet.sumOfAllPetAges += yourPet[i].age;
for (int i=0; i<numberofpets; i++)
System.Console.WriteLine("The age of the pet is " + Convert.ToString(yourPet[i].age) + ", the pet's name is " + yourPet[i].name + ", and the breed of the pet is " + yourPet[i].breed + ".");
Pet youngest = yourPet[0];
for (int i=0; i<numberofpets; i++)
if (yourPet[i].age >= oldest.age)
if (yourPet[i].age <= youngest.age)
System.Console.WriteLine(youngest.name + " is the youngest pet.");
System.Console.WriteLine(oldest.name + " is the oldest pet.");
double sum = (double) Pet.sumOfAllPetAges / (double) Pet.totalNumberOfPets;
System.Console.WriteLine("The average age of the pet(s) is " + sum + ".");