Thread: C++ Data input & variables - please help

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    11

    Unhappy C++ Data input & variables - please help

    Hi. I'm new to C++ and I would really appreciate if someone could help me out with a program I'm writing. I want to write a program that needs to calculate working hours at the workplace.

    1. It should print out prompt "Enter data: " and the user types in four numbers: the hours and then minutes for clocking in followed by the hours and minutes for clocking out in the form "12 30 16 45".

    2. Both input times should be converted to a total number of minutes since midnight. E.g. 01:30 would be represented as 90 minutes.

    3. Calculate result by subtracting these figures to obtain the required time interval in minutes. This should be converted to a number of hours and minutes before printing the result in the format: "4h15" and using 24-hour clock times.

    Thanks.
    giggsy.

  2. #2
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Thumbs up Hello!

    Can you post some of your code. Dont forget to use code tags e.g.
    Code:
     and
    . most people get bent out of shape when this isnt down.
    Let everyone see what you started even if its a few lines giggy.
    Later.
    cj
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  3. #3
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Hi,

    I think you shouldn't just post the whole question, just try to start with it and when you are stuck somewhere, just post it, and we will be more than happy to help you.

    Welcome to this forum.

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    11

    Smile

    Thanks for your reply guys. Will do as you have requested. In the meantime I have another question.

    I have to write suitable variable declarations and C++ boolean expressions to test the following conditions:

    The value of sex is 'M, m, F, f'.

    I just need to know how to declare these as variables. I'm ok with boolean expressions.

  5. #5
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    You can so the following:
    Code:
    char sex;
    cin >> sex;
    if ( sex == 's' || sex == 'S' )
         //something
    else //you can make other conditions...
    Is this what you need?

    Note: you can also use cin.get() or getch() instead of cin, it's up to you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 06-14-2005, 05:45 AM
  2. Problem with Printing message
    By robert_sun in forum C Programming
    Replies: 2
    Last Post: 05-16-2004, 02:09 PM
  3. C diamonds and perls :°)
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-16-2003, 10:19 PM
  4. reading input files with different types of data
    By sanu in forum C++ Programming
    Replies: 4
    Last Post: 06-27-2002, 08:15 AM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM