Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 equation help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
RENThead




PostPosted: Thu Feb 22, 2007 1:18 pm   Post subject: equation help

i've been having a problem trying to do an assignment for school, and i'm not trying to ask anyone to do it for me cuz i know how to put it in code but i'm having a problem finding a formula this is the question

Quote:
a parking garage charges by the following fee schedule:
1.50 for the first thirty minutes
1.25 for each additional halfhour of part thereof for the next 4.5 hours, this will account then for the first 5 hours
1.50 for each additional hour (past the 5 hours) or part thereof to a maximum of 20.00 for the entire stay.


i'm suposed to beable to make the user input how many minutes they stayed and then the program give them the cost. the only equation i got was:
Quote:

(timee - 30) / 30 * 1.25 + basecharge

var basecharge : real := 1.50 %the 1.50 for the first 30 min.
var timee : real %the person puts in the minutes


does this seem rite? or am i doing something wrong?
Sponsor
Sponsor
Sponsor
sponsor
zylum




PostPosted: Thu Feb 22, 2007 3:13 pm   Post subject: RE:equation help

code:
1.5 + max (0, min (9, n - 1)) * 1.25 + (max (0, n - 9) div 2) * 1.5

where n is the number of half hours.

1.5 is the base charge, max (0, min (9, n - 1)) * 1.25 is the next 4.5 hours and (max (0, n - 9) div 2) * 1.5 is the rest of the time. using the max and min functions i am able to keep the value in a certain range.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: