Day counter with while loop - CSharp Language Basics

CSharp examples for Language Basics:while

Description

Day counter with while loop

Demo Code

using System;/*from   ww  w.  j  ava2 s  . c om*/
class DayCounter
{
   public static void Main()
   {
      uint dayCounter = 0;
      uint maxSimulationDays;
      uint weeks;
      byte remainderDays;
      maxSimulationDays = 10;
      while(dayCounter < maxSimulationDays)
      {
         dayCounter++;
         weeks = dayCounter / 7;
         remainderDays = (byte)(dayCounter % 7);
         Console.WriteLine("Weeks: " + weeks + "   Days: " + remainderDays);
         if(remainderDays == 0)
            Console.WriteLine("\t\tHey Hey It's Sunday!");
         System.Threading.Thread.Sleep(200);
      }
   }
}

Result


Related Tutorials