Computer Science Canada parking garage |
Author: | Jenkinz [ Thu May 04, 2006 8:04 am ] | ||
Post subject: | parking garage | ||
Im trying to make ap arking garage that will tell me how much customers owe me based on the number of hours they have parked in my garage, i have an array of people that hold am onthly pass, and the user ahs to tell me their ticket number. If their ticket number matches the list of passes they will not owe anything, o else i mus calculate how much they owe me. To calculate how much the client owes me i need a program that will be based on a 24 horu clock i.e 00:00 is 12:00 midnight, 13:30 is 1:30 in the afternoon, and will calculate the time in the garage at $1.00/per half an hour with a 10.00$ daily maximum, this is what i have so far and it doesn't seem to be co-operating any help would be appreciated.
|
Author: | Jenkinz [ Thu May 04, 2006 8:52 am ] | ||
Post subject: | |||
how would i be able to make it so that this program would be able to calculate minutes as well, so if the user entered at 2, and left at 2:25?
|
Author: | ll22 [ Fri May 05, 2006 8:43 am ] |
Post subject: | |
You could ask the user how much time they have been there total (hours and minutes). Or you would have to set it up so that the program recognizes the difference between AM and PM time and then calculates the difference between the times. The way it is set up now you get negative amounts if you enter 10 and 1. How about using 24-hour time? |
Author: | Jenkinz [ Sun May 07, 2006 4:00 pm ] |
Post subject: | |
yea, thats exactly what i was trying to do, but for some reason it wasn't going along, I.E when you said you entered at 13, and left at 14.50, it would come up as something such as your charge would be .60 |
Author: | jamonathin [ Sun May 07, 2006 7:58 pm ] | ||||
Post subject: | |||||
What you need to realize is you are trying to turn a decimal number into time. What you aren't doing is seeing that from 1:00 to 2:30 will give you a decimal number of 1.3. Take a good look at 1.3 - what can you get from that. The 1 represents hours, the .3 represents minutes, correct? So how do you incorporate this into costs and whatnot, and how do you extract the values? You can divise a formula to fit into 1 variable, but lets split this up a bit. Hours:
Minutes:
That is how you would extract time from a real number. The rest is up to you, afterall it is your assignment ![]() Hint: You will need to convert your minutes into a whole number, then divide them by a certain time factor. |