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

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




PostPosted: 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.

code:
var pass : array 1 .. 10 of int := init (1234, 4321, 2345, 5432, 3456, 6543, 4567, 7654, 5678, 8765)
var time1 : int
var time2 : int
var answer : int
for i : 1 .. 10
    var found : boolean := false
    if pass (i) = answer then
        found := true
    end if
    put "what is your pass number?"
    get answer
    if found = true then
        put "You owe no money, you may proceed."
    else
        put "You are not a member please enter the time you arrived"
        get time1
        put "please enter the time you left"
        get time2
    end if
end for
Sponsor
Sponsor
Sponsor
sponsor
Jenkinz




PostPosted: Thu May 04, 2006 8:52 am   Post subject: (No 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?

code:
var number : string
var list : array 1 .. 10 of string := init ("1234", "4321", "2345", "5432", "3456", "6543", "4567", "7654", "5678", "8765")
var found : boolean := false
var total : real
var time_in : real
var time_out : real
put "please enter your number"
get number
for i : 1 .. 10
    if list (i) = number
            then
        found := true
    end if
end for
if found = true
        then
    put "thank you for coming"
end if
if found = false
        then
    put "you have not registered with the garage when did you enter?"
    get time_in
    put "what time did you leave?"
    get time_out
    total := (time_out - time_in) * 1 * 2/30
end if
if found = true
        then
    total := 0
end if
if total >= 10.00 then
total := 10.00
end if
put "this is your total"
put total : 3 : 2

ll22




PostPosted: Fri May 05, 2006 8:43 am   Post subject: (No 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?
Jenkinz




PostPosted: Sun May 07, 2006 4:00 pm   Post subject: (No 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
jamonathin




PostPosted: Sun May 07, 2006 7:58 pm   Post subject: (No 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:
pseudo:

Hours := Floor (endTime - startTime)

Minutes:
pseudo:

Minutes := (endTime - startTime) - Hours


That is how you would extract time from a real number. The rest is up to you, afterall it is your assignment Razz .

Hint: You will need to convert your minutes into a whole number, then divide them by a certain time factor.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: