• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help figuring out some arithmatic...  RSS feed

 
Hayden Pynappels
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heyas,
So I'm having a bit of trouble calculating a fee in a class I'm trying to write. One of the methods in this class is used to calculate said fee. The fee depends on how long a car stays in its parking slot.
If it's been there 0-3 hours, its a flat $3 fee. Over 3 hours and it's an additional $1.50 an hour with a maximum charge of $12 per 24hours. There is no limit to the amount of days they can stay...
I have 3 arrays that are holding the date, hour and minute (that has to be rounded to the NEAREST hour) respective of each parking slot. (dayIn, hourIn and minIn) and 3 separate variables that hold the current date, hour and min.

Anyways, my question is how would I go about calculating the fee?

Cheers,
 
Marcus Kelvin
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Division / and modulus % with integers, which are rounded down.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hayden Pynappels wrote:I have 3 arrays that are holding the date, hour and minute (that has to be rounded to the NEAREST hour) respective of each parking slot.

Seems an odd way to do things. Why not just write a ParkingSlot class?

Winston
 
Hayden Pynappels
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems an odd way to do things. Why not just write a ParkingSlot class?

It's for an intro class. That seems slightly past my knowledge atm :P

Division / and modulus % with integers, which are rounded down.

I'm not good with maths, how would I implement it?
I'm aware of what the operators do, I'm just not so good on the maths side of things...
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!