Go to Top

Friday 30 September 2011

Utilities 8 - Stopwatch

Here's a simple program that can act as a Java Stopwatch Timer.

Java Program :

class stopwatch
{
 static void main()
 {
    long s=0,m=0,h=0;
     for(;;)
     {
       
         try
         {Thread.sleep(1000);}
         catch(InterruptedException e)
         {}
         s=s+1;
            if(s==60)
            {
                s=0;
                m=m+1;
                }
            if(m==60)
            {
                m=0;
                h=h+1;
            }
            System.out.print("\f");
            System.out.print("Timer : "+s+" : "+m+" : "+h);
        }
    }
}
           

No comments:

Post a Comment

ShareThis