Big Moose Saloon
 Search | Java FAQ | Recent Topics Register / Login

# Help figuring out some arithmatic...

Hayden Pynappels
Greenhorn

Joined: May 05, 2012
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

Joined: Jan 04, 2012
Posts: 44
Division / and modulus % with integers, which are rounded down.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 6136

12

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

Isn't it funny how there's always time and money enough to do it WRONG?
Hayden Pynappels
Greenhorn

Joined: May 05, 2012
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...

Don't get me started about those stupid light bulbs.

subject: Help figuring out some arithmatic...