
-----------------------------------
RENThead
Fri Feb 23, 2007 1:22 pm

max limit
-----------------------------------
how do i make it so that an eqation in my program can only have one max anwser? 


var timee : real
var total : real
var basecharge : real := 1.50

put "Please type in how many minutes you were parked in the garage then press enter."
get timee


if timee  30 and timee  60 * 5 then
    total := ceil ((timee / 60) - 5 * 1.50) + 1.50 + (5 * 2.1 * 1.50) 
end if

put "this is what you should pay ", total : 0 : 2


how do i make it so that the person only has to pay 20.00 max

-----------------------------------
Cervantes
Fri Feb 23, 2007 2:19 pm

RE:max limit
-----------------------------------
How about this:


var maxcharge : real := 20.00
if timee  30 and timee  60 * 5 then
    total := maxcharge
end if 


Maybe I don't understand exactly what you're trying to do.

-----------------------------------
Abstraction
Fri Feb 23, 2007 5:35 pm

Re: max limit
-----------------------------------
I guess you could add something right before the output statement like this:

if total >= 20
     then total := 20
end if

-----------------------------------
Clayton
Fri Feb 23, 2007 5:46 pm

Re: max limit
-----------------------------------
which is what he did (albeit a bit shrouded). the 


if timee > 60 * 5 then
...
end if


translates into, if the time is greater than 5 hours, then the total is equal to 20
