I asked a question in the WriteLine form that requires a numbered input, converted it to an int, used that int in an if-else, and I want the question to be re-asked afterward. Any idea?
Example:
Console.WriteLine("What hour is it?: ");
int hour = Convert.ToInt32(Console.ReadLine());
if (hour > 0 && hour < 12)
{
Console.WriteLine("It's morning.");
}
if (hour > 12 && hour < 18)
{
Console.WriteLine("It's evening.");
}
else if (hour > 18 && hour < 24)
{
Console.WriteLine("It's night.");
}
else
{
Console.WriteLine("Invalid Input.");
}
Aucun commentaire:
Enregistrer un commentaire