programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Help figuring out some arithmatic...

Hayden Pynappels
Greenhorn
Posts: 2
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
Division / and modulus % with integers, which are rounded down.

Winston Gutkowski
Bartender
Posts: 10575
66
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
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.