need help in time zone

This is a discussion on need help in time zone within the C++ Programming forums, part of the General Programming Boards category; (Task 1) User enters the time of city A, time difference between cities A and B, and the program will ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    8

    need help in time zone

    (Task 1) User enters the time of city A, time difference between cities A and B, and the program will output the equivalent time of city B.



    Define and implement a class Time. Time difference is a positive value if time of city B is ahead of city A. It is a negative value if time of city B is behind city A.

    Typical Sample Runs for Task 1 (user inputs in bold):
    Enter hrs, mins and am/pm of time of city A: 2 10 pm
    Enter time difference (in hrs) between cities A & B: 6
    The equivalent time of city B is 8:10 pm.

    Enter hrs, mins and am/pm of time of city A: 9 45 am
    Enter time difference (in hrs) between cities A & B: -3
    The equivalent time of city B is 6:45 am.


    Can someone help me or got any sample. My C++ not so good.. Thanks.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,334
    Never mind the C++, do you understand the maths which is needed for this?

    Hint:
    Convert hh:mm into hh*60+mm
    Then perform the calculation.
    Then convert the result back into hh:mm
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    Quote Originally Posted by Salem
    Never mind the C++, do you understand the maths which is needed for this?

    Hint:
    Convert hh:mm into hh*60+mm
    Then perform the calculation.
    Then convert the result back into hh:mm
    before it convert the 12h PM/AM format to the 24h format
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Representing floats with color?
    By DrSnuggles in forum C++ Programming
    Replies: 113
    Last Post: 12-30-2008, 08:11 AM
  2. Using pointers
    By Big_0_72 in forum C Programming
    Replies: 3
    Last Post: 10-28-2008, 07:51 PM
  3. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 05:00 PM
  4. Checking parts of a structure
    By DocDroopy in forum C Programming
    Replies: 11
    Last Post: 08-05-2002, 07:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21