Hi again,
I have a small application that calculates time left over in a day after events.
The problem I have is that if either the starting time or ending time is 4.10 or 5.10 I get slightly incorrect answer.
Eg.
if the only event starts at 4 and ends at 4.10, it outputs that I have 23 hours and 51 minutes free (instead of 50 minutes)
Or if the event is 5.10 until 6, it outputs 23 hours and 9 minutes.

These are the only times that give incorrect answers.
I can post my code if its necessary, but was just wondering if this is a common problem easily overcome?

Thanks.

im no expert but it sounds like minor problem is causing it , post ur code and lets see

Ok, here is my method;

public int calculateMinsleft (Lecture other, Lecture other2, Lecture other3, Lecture other4){ //calculate minutes left
return (1440-(minutes+other.minutes+other2.minutes+other3.minutes+other4.minutes))-(((1440-(minutes+other.minutes+other2.minutes+other3.minutes+other4.minutes))/60)*60);
}

"minutes" are the duration of each lecture in minutes.

I just patched it up with an ugly while statement which will suffice, but I'd love to learn what's going on here.

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.