• C

# This is for IMLADRIS, KAMENIM

int Minutes(int s_hour, int s_minute, int e_hour, int e_minute, int *start)
{
int iStart = s_hour *24 + s_minute;
int iEnd = e_hour *24 + e_minute;

if (iStart > End)
iEnd += 24*+60;
*start = iStart;
return iEnd - iStart;
}
//s_time: start time
//c_time: duration
//return money

double Bill (double c_time, int s_time)
{
double charge;
if ((s_time > 8) || (s_time < 18))
{
charge = full_price * c_time;
if (c_time > 60)
charge -= charge * 0.1;
}
else
{
charge = discount *c_time;
if (c_time > 60)
charge -= charge * 0.1;
{
return charge;
}
This is suppose to read into a file that has these duration and charges
it keeps coming out to something else it supposed to be this 4.50, 3.75, 23.62
and the durations are 30, 15, 105
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
minutes = 60*(end_hour - start_hour) + (end_minute - start_minute);
0
Commented:
>> if (c_time > 60) charge -= charge * 0.1;
Can be brought outside the outher if-then.

>> if ((s_time > 8) || (s_time < 18))
is always true...
0
Commented:
Without knowing full_price, discount and s_time, there is no apparent way of checking results.

Kangaroo has made a couple of relevant points.

I don't think his proposed statement will cope with start hours that are greater than end hours. I would write Minutes as:

int Minutes(int s_hour, int s_minute, int e_hour, int e_minute, int *start)
{
int iStart = s_hour *60 + s_minute;
int iEnd = e_hour *60 + e_minute;

if (iStart > End)
iEnd += 24*60;
*start = iStart;
return iEnd - iStart;
}

That is, multiply the hours by 60 (not 24) and change the iEnd += from 24*+60 to just 24*60.
0
Commented:
Was there something else you needed clarified before you accept or grade an answer?
0
Commented:
I guess that answered it then....
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
I actually finished the program before you answered the question.  Thanks
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.