Im am having abit of trouble with a while loop.
I have this method which determines wether or not the entered year is a leap year, the while loop is intended to keep asking the user for another year until he/shes wishes to exit the program.
Here is my method:
static int Main(string[] args)
{
InputWrapper iw = new InputWrapper();
Console.WriteLine("Enter -1 at any time to terminate the program");
int year = iw.getInt("Year: ");
while(year != -1)
{
if(DateTime.IsLeapYear(year))
{
Console.WriteLine("{0} is a leap year", year);
}
else
{
Console.WriteLine("{0} is not a leap year", year);
}
Console.ReadLine();
}
return 0;
}
I have been trying to figure this out for a good hour, it seems basic enough but i cant get it.
How do I get it to keep repeating until the user exits?