?
Solved

This is for IMLADRIS, KAMENIM

Posted on 1999-12-14
6
Medium Priority
?
242 Views
Last Modified: 2010-04-15
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
0
Comment
Question by:salfam
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2282883
minutes = 60*(end_hour - start_hour) + (end_minute - start_minute);
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2282892
>> 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
 
LVL 16

Expert Comment

by:imladris
ID: 2283717
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 16

Expert Comment

by:imladris
ID: 2288017
Was there something else you needed clarified before you accept or grade an answer?
0
 
LVL 16

Accepted Solution

by:
imladris earned 320 total points
ID: 2303607
I guess that answered it then....
0
 

Author Comment

by:salfam
ID: 2304372
I actually finished the program before you answered the question.  Thanks
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question