Thread: Basic C Programming help!

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    So how did *you* work out that the time spent was 46 hours 25 minutes? That process is what you want to put into code, so you had better know what it is.

  2. #17
    Registered User
    Join Date
    Feb 2014
    Posts
    10
    Quote Originally Posted by tabstop View Post
    So how did *you* work out that the time spent was 46 hours 25 minutes? That process is what you want to put into code, so you had better know what it is.

    I think I got it!?1 ( 24 - returned hour ) + ( 24 - rented hour) = totalrentdays, do the same for minutes? I'll try that and see what happens...

  3. #18
    Registered User
    Join Date
    Jan 2014
    Posts
    10
    I don't see how only calculating the equation above gives you the total days of rental. What about months? Years? Days? Minutes? All of these contribute to total days.

    How exactly does the output need to be formatted? In one post you mentioned only hours and minutes, whereas in another you mentioned date and time in military format. For example, if you only need to display total number of hours and minutes rented, it would make more sense to convert the year, month, and day differences into simply hours (since it will be a whole number) and calculate the minute difference separately.

  4. #19
    Registered User
    Join Date
    Feb 2014
    Posts
    10
    Thank you all for the help.

    I found the core equation that I needed
    Code:
        totalreturnTime = (returnyear * 365 * 24 * 60) + (returnmonth * 31 * 24 * 60) + (returnday * 24 * 60) + (returnhour * 60) + (returnmin); 
        totalrentTime = (rentyear * 365 * 24 * 60) + (rentmonth * 31 * 24 * 60) + (rentday * 24 * 60) + (hour * 60) + (min);
        rentTotal = totalreturnTime - totalrentTime;
        totalTimeHour = rentTotal / 60;
        totalTimeMin = rentTotal - (totalTimeHour * 60);
    and now I just have to fix up the cost and find out how to account for leap years...!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very basic OOP programming in C
    By patishi in forum C Programming
    Replies: 2
    Last Post: 12-20-2013, 03:08 PM
  2. help with my basic c programming
    By chris199236 in forum C Programming
    Replies: 15
    Last Post: 09-25-2012, 09:23 PM
  3. Basic C programming 3
    By vivekgupta in forum C Programming
    Replies: 10
    Last Post: 06-13-2012, 11:22 AM
  4. Basic C programming -1
    By vivekgupta in forum C Programming
    Replies: 29
    Last Post: 06-11-2012, 03:26 PM
  5. basic C-programming Q
    By slyonedoofy in forum C Programming
    Replies: 2
    Last Post: 10-30-2002, 09:54 PM