Closed Thread
Results 1 to 10 of 10

Thread: need help [ time remaining ]

  1. #1
    Amonijack is offline Learning Programmer
    Join Date
    Apr 2009
    Posts
    56
    Rep Power
    0

    need help [ time remaining ]

    Code:
    program codecall;
    var i,n,m,j:integer;
    begin
         write('hour    ? : ');
         readln(n);
         write('minutes ? : ');
         readln(m);
         if (n>=0) and (n<=24) and (m>=0) and (m<=60) then
             for i:=1 to m do
             for j:=1 to n do
             begin
             if m mod 5 = 0 then
               writeln('now is ',n,' hour and ',m,' mins !')
                else
                  m:=m+1;
             end;
         readln;
    end.
    this is exam for me
    after 5 mins write " now is X hour and Y mins"
    my program not work corectly. :S
    i need help.
    thanks in advance

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: need help [ time remaining ]

    Have you considered using the sleep function?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Amonijack is offline Learning Programmer
    Join Date
    Apr 2009
    Posts
    56
    Rep Power
    0

    Re: need help [ time remaining ]

    I dont know how to use this function :S
    Can anybody explain me ?

  5. #4
    Amonijack is offline Learning Programmer
    Join Date
    Apr 2009
    Posts
    56
    Rep Power
    0

    Re: need help [ time remaining ]

    :S
    No help for me ?

  6. #5
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: need help [ time remaining ]

    OK, first problem: you aren't using the now() function to find out when 5 minutes have passed.
    Doing it brute force: you would need to get the current time when the program starts.
    Then you would need to calculate when 5 minutes later would be.
    Then you would need to wait (using a while loop or something) until now() returns a time later than 5 minutes after the program started.
    Then you can output the hour/minute component of that time.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  7. #6
    Amonijack is offline Learning Programmer
    Join Date
    Apr 2009
    Posts
    56
    Rep Power
    0

    Re: need help [ time remaining ]

    i dont know how to convert minutes in hour.
    60 mins = 1 hour and i dont know this part/step in my code :S
    any idea ?

  8. #7
    Amonijack is offline Learning Programmer
    Join Date
    Apr 2009
    Posts
    56
    Rep Power
    0

    Re: need help [ time remaining ]

    ok, i find one code, i think that this code will help me to finished my program

    hier is code

    Code:
    function timer:real;
    var hour,minute,second,sec100:word;
    begin
       gettime(hour,minute,second,sec100);
       timer:=(hour*3600.0+minute*60.0+second)*100.0+1.0*sec100;
    end;
    
    procedure wait_seconds(t:real);
    var t1:real;
    begin
     t1:=timer;
     repeat until timer>t1+100*t;
    end;
    can anybody explain me this code ? PLEASE

    step by step

    thank you in advance

  9. #8
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: need help [ time remaining ]

    timer returns the number of hundredths of a second since midnight.
    wait_seconds sits in a loop until the specified number of seconds have passed.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  10. #9
    Amonijack is offline Learning Programmer
    Join Date
    Apr 2009
    Posts
    56
    Rep Power
    0

    Re: need help [ time remaining ]

    ok. i like to make program who will write on screen hour, mins and seconds. for example
    input >
    1 hour 4 mins
    output >
    1 hour 9 mins
    after 5 mins
    now 1 o'clock 14 mins
    ........
    ..........
    4 o'clock and 2 mins
    after 5 mins
    4 o'clock and 7 mins

    i dont know how to make TIME REMAINING :S

    that is my problem
    please for help

  11. #10
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: need help [ time remaining ]

    I'm not sure if you're having problem with the decodetime function, or something else.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. howdy! long time listener first time caller
    By darkresearcher in forum Introductions
    Replies: 2
    Last Post: 05-31-2011, 04:20 PM
  2. How to compute time in Turbo C 2.0 using time.h
    By madmhan84 in forum C and C++
    Replies: 7
    Last Post: 04-06-2011, 12:58 AM
  3. Adding time to string time
    By lol33d in forum PHP Development
    Replies: 1
    Last Post: 02-08-2011, 11:37 AM
  4. Replies: 1
    Last Post: 03-31-2010, 10:46 PM
  5. ASP time
    By probashi in forum General Programming
    Replies: 1
    Last Post: 11-18-2009, 07:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

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