Advertisement

07.24.2008 at 07:14AM PDT, ID: 23592138
[x]
Attachment Details

Help to improve a function that works with hours

Asked by hidrau in Delphi Programming

Hello guys

I have this function that returns me a message if I am late, on track or ahead with my plan study, see this examplo:

HoursPerMonthChosen = 40
HoursStudy='30'

I noticed that If I have an amount of study hours this way: 30:43 I have an wrong calculation.
Other thing, the function starts to count the first day of my month, as I am at 23 and I have studied already 35 hours and I have many days ahead to accomplish my studies, I can't be late. This functions is not working fine.

I would also like to have a return how mnay hours now I shoud study to accomplish my goal.
If I chose 40 hours per month and I have already 35 hours studied until now (day 23) and I have more 7 days ahead to accomplish it, then how many hours or minutes I need to accomplish my goal? This function could return me also in the text , something like this:

You are ahead by xx hours and now you can study only xx minutes per day to accomplish your goal

Thanks

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
uses math;
 
function Late(hoursPerMonth : Integer; HoursStudied: String; IncludeWeekEnd: Boolean): String;
var hs, d, avg: Double;
begin
  hs := StrToFloatDef(HourStudied, 0);
  d := DayOf(Now);
  avg := hoursPerMonth / IfThen(IncludeWeekend, 30, 22);
  if d * avg > hs then
    Result := 'you are late by ' + FloatToStr(d * avg - hs) + ' hours'
  else if d * avg < hs then
    Result := 'you are ahead by ' + FloatToStr(d * avg - hs) + ' hours'
  else
    Result := 'you are exactly on track';
end;
[+][-]07.24.2008 at 08:06AM PDT, ID: 22079973

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 08:15AM PDT, ID: 22080083

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 08:19AM PDT, ID: 22080125

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 08:25AM PDT, ID: 22080198

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.28.2008 at 06:57AM PDT, ID: 22103143

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Delphi Programming
Sign Up Now!
Solution Provided By: Geert_Gruwez
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.28.2008 at 07:53AM PDT, ID: 22103725

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.28.2008 at 11:34AM PDT, ID: 22105624

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 05:14AM PDT, ID: 22119619

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.31.2008 at 12:19AM PDT, ID: 22127550

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.31.2008 at 03:26AM PDT, ID: 22128349

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.01.2008 at 01:02AM PDT, ID: 22136254

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.01.2008 at 05:34AM PDT, ID: 22137602

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628