Argh!! Please help! I’ve been wrestling with what should be a straightforward code for this challenge project and I cannot get it to stop looping through! I’m sure it’s a silly mistake, but I can’t find it. Why, after the user enters the required data for the only animal with missing physical data, does my code ask for them to enter physical data for an animal without data?
do
{
for (int i = 0; i < maxPets; i++)
{
if (ourAnimals[i,0] != "ID#: ")
{
if (ourAnimals[i,4] == "Physical description: ") // check for an empty physical description
{
string updatedPhysicalDescription = "";
Console.WriteLine ($"Enter a physical description for {ourAnimals [i,0]} (size, color, breed, gender, weight, housebroken)");
readResult = Console.ReadLine();
while (updatedPhysicalDescription == "")
{
if (readResult != null)
{
updatedPhysicalDescription = readResult.ToLower();
do
{
if (updatedPhysicalDescription != "")
{
animalPhysicalDescription = updatedPhysicalDescription;
validEntry = true;
}
else
{
Console.WriteLine ("Please enter a description of the pet.");
readResult = Console.ReadLine ();
}
} while (updatedPhysicalDescription == "");
}
}
}
}
}
} while (validEntry == false);
"
Welcome to the Contoso PetFriends app. Your main menu options are:
- List all of our current pet information
- Add a new animal friend to the ourAnimals array
- Ensure animal ages and physical descriptions are complete
- Ensure animal nicknames and personality descriptions are complete
- Edit an animal’s age
- Edit an animal’s personality description
- Display all cats with a specified characteristic
- Display all dogs with a specified characteristic
Enter your selection number (or type Exit to exit the program)
3
Enter an age for ID #: c4
1
Enter a physical description for ID #: c4 (size, color, breed, gender, weight, housebroken)
small
Enter a physical description for ID #: (size, color, breed, gender, weight, housebroken)
"