+ Reply to Thread
Results 1 to 6 of 6

Thread: A digital clock in Console

  1. #1
    Newbie kiekkopojka8 is an unknown quantity at this point
    Join Date
    Feb 2010
    Posts
    3

    A digital clock in Console

    Hey, I want to know how to make a digital clock in console appl. with hours, mins and seconds. But I don't know how.

    The funny thing is that our teacher is kinda bad so I don't get any help from him, which makes it hard to do stuff in C#.

  2. #2
    Learning Programmer cdg10620 is an unknown quantity at this point cdg10620's Avatar
    Join Date
    Jun 2009
    Location
    Texas
    Posts
    99
    Blog Entries
    3

    Re: A digital clock in Console

    Do you need the clock to run in the console and just display the current time? What code do you have for this so far? Can you post what you currently have?

    Quote Originally Posted by kiekkopojka8 View Post
    Hey, I want to know how to make a digital clock in console appl. with hours, mins and seconds. But I don't know how.

    The funny thing is that our teacher is kinda bad so I don't get any help from him, which makes it hard to do stuff in C#.

  3. #3
    Programming Expert Bartimäus is on a distinguished road Bartimäus's Avatar
    Join Date
    Dec 2009
    Location
    Germany
    Posts
    491

    Re: A digital clock in Console

    I have found an example maybe its helpful for you:
    C# Home

  4. #4
    Newbie kiekkopojka8 is an unknown quantity at this point
    Join Date
    Feb 2010
    Posts
    3

    Re: A digital clock in Console

    Quote Originally Posted by cdg10620 View Post
    Do you need the clock to run in the console and just display the current time?
    Yes

    Quote Originally Posted by Bartimäus View Post
    I have found an example maybe its helpful for you:
    C# Home[/url]
    Thanks, I'll check it out

  5. #5
    Newbie kiekkopojka8 is an unknown quantity at this point
    Join Date
    Feb 2010
    Posts
    3

    Re: A digital clock in Console

    Ok guys.

    I got this far:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    {
    int choice = 0;

    int h = 0; /*Hours*/
    int m = 0; /*Minutes*/
    int s = 0; /*Seconds*/


    do

    {
    Console.WriteLine("My menu");
    Console.WriteLine("1- Show watch");
    Console.WriteLine("0- Close");
    Console.WriteLine("Choice: ");

    choice =Convert.ToInt32(Console.ReadLine());

    if (choice == 1)
    {
    //Show the clock
    Console.WriteLine("Clock");

    Console.ReadLine();
    }



    } while (choice != 0);

    }
    }
    }


    As you can see I did a menu where you can choose between showing the clock and close it.

    I must use System.Threading.Thread.Sleep(); and Console.Clear();

    Seconds changes to minutes and minutes changes to hours. It starts again after 12 hours.

    I've never did anything which contains these. = I need help

  6. #6
    Learning Programmer lobo521 is on a distinguished road
    Join Date
    Jan 2010
    Posts
    46

    Re: A digital clock in Console

    Use Timer class. Timer in C#

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Clock class
    By Groogy in forum C and C++
    Replies: 10
    Last Post: 01-03-2010, 06:42 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts