计算以小时数表示的总工作时间 [英] Calculate total working hours where hours passed as a number
本文介绍了计算以小时数表示的总工作时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用FLEX 3.0版,我想计算总工作时间.我正在为您提供详细信息以及我在其中所做的工作.
I am using FLEX version 3.0 I want to calculate the total working hours. I am giving you the details and what i have done in it.
var a:Number = 2.00;
var b:Number = 2.00;
var c:Number = 1.45;
var d:Number = 1.30;
var total:Number = a+b+c+d;
var totalmin:int = total;
var temp:Number = total - totalmin;
var tem2:Number = 0.60 - temp;
var workhour:Number = 0;
while(total >= 0)
{
workhour += 1;
total -= 1.00;
}
var tot:Number = workhour + tem2;
txtTotal.text = tot.toString();
我想要结果7.15而不是6.75.目前我的评分为6.85 ...请帮助解决此问题.
I want result 7.15 not 6.75. currently i am getting 6.85... please Help to solve this issue.
thanks in advance.
推荐答案
可能与一个小时包含60分钟而不是100分钟有关吗?所以1 3/4小时不是1.45,而是1.75?而1 1/2小时不是1.30而是1.50?
Could it have anything to do with the fact that an hour contains 60 minutes, not 100? So 1 3/4 hours is not 1.45, but 1.75? and 1 1/2 hours is not 1.30 but 1.50?
在这行
var tem2:Number = 0.60 - temp;
您需要像这样颠倒减法的顺序
you need to reverse the order of subtraction like so
var tem2:Number = temp - 0.60;
这将总共给您7.15
this will give you a total of 7.15
我为此做了很多工作,并找到了一个有趣的问题.....我已经找到了正确的答案.继续发布有趣的问题.
这是代码.
I have worked a lot on this one and find one of the interesting questions..... and i have found the correct answer for that.. Keep posting that interesting questions.
here is the code.
var a:Number = 2.23;
var b:Number = 2.36;
var c:Number = 1.18;
var d:Number = 1.13;
var totalHours = 0.0;
var inta:int = a;
var numa:Number = a - inta;
var intb:int = b;
var numb:Number = b - intb;
var intc:int = c;
var numc:Number = c - intc;
var intd:int = d;
var numd:Number = d - intd;
var total:int = inta + intb + intc + intd;
var totalsec:Number = numa + numb + numc + numd;
var tempsec:int = totalsec * 100;
var temp:int = tempsec/60;
total += temp;
var sec:Number = tempsec - (temp*60);
sec = sec/100;
totalHours = total + sec;
txtTotal.text = totalHours.toString();
这篇关于计算以小时数表示的总工作时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文