%Isabella Jawan
%30th September 2003
%This program will calculate the amount of parking charges that should be
%charged at the given amount of time
%----------------------------Program Listings--------------------------------
var answer: string %declares answer as string
var totalminutes,minutes,fee,hours: real %declares totalminutes,minutes,
%fee and hours as real
var x:int %declares x as integer
var totalfee:real %declares totalfee as real
locate (10,25) %locates items on given rows and
%columns in brackets
put "WELCOME to Bella's Garage" %displays welcome message to user
locate (11,24)
put "~~Where your car belongs~~"
locate (20,30)
put "Loading..." %displays words in brackets
delay (1000) %delays next action by specified
%thousandth of a second
cls %clears screen
loop %starts loop structure
locate (1,1)
put chr (201) %displays set character
locate (2,1)
for i:1..22 %starts nested counted loop
put chr (186)
end for %ends nested counted loop
put chr (200)
locate (1,2) %locates number of rows & columns
%specified in brackets
put repeat(chr(205),77)
locate (1,78)
put chr (187)
x:=0 %x is initialized
for i:1..22 %starts nested counted loop
x:=x+1 %starts accumulator
locate (1+x,78)
put chr (186)
end for %ends nested counted loop
locate (24,2)
for i:1..76 %starts nested counted loop
put chr (205)..
end for %ends nested counted loop
locate (24,78)
put chr (188)
delay (500)
locate (2,33)
put "Welcome!" %displays welcome message to user
locate (1,30)
put "BELLA'S GARAGE" %cuts and paste words onto output
%screen
locate (18,10)
put "Please enter prompted information"
locate (18,45)
put "below this line" %tells user where to enter needed
%information
locate (19,2)
for i:1..76
put "-".. %puts a divider
end for
locate (19,5)
put "HOW MANY" %displays words in quotes
delay (200)
locate (20,3)
put "hours has your car been parked ? "..%prompts user to enter number of
%hours car has been parked
get hours %retrieves hours
locate (20,3)
for i:1..50 %starts nested counted loop
put " "..
end for %ends nested counted loop
if hours <0 then %starts selection structure
loop %starts nested loop structure
locate (20,3)
put "Please enter a positive number:"..
%prompts user to enter a positive
%number of hours
get hours %retrieves hours
for i:3..40 %starts nested counted loop
put " ".. %clears line
end for %ends nested counted loop
exit when hours >0 %exits when hours is more than
%0
end loop %ends nested loop structure
end if %ends selection structure
locate (4,4)
put "Hours parked" %displays words in brackets on
locate (5,2)
put repeat (chr (196),76) %displays a divider
locate (6,8)
put hours %displays hours entered
delay (200)
locate (20,3)
put "minutes has your car been parked?"..%prompts user to enter
%the amount of minutes they
%they have parked their car
get minutes %retrieves minutes entered
locate (19,3)
put "------------" %puts a divider
locate (20,3)
for i:3..30 %starts nested counted loop
put " ".. %clears the line
end for %ends nested counted loop
if minutes <0 then %starts if structure
loop %starts nested loop structure
locate (19,3)
put "Please enter a number between "..%prompts user to enter a
put "0 and 59:".. %number between 0 and 59
get minutes %retrieves minutes
locate (19,3)
for i:2..50
put " ".. %clears line
end for
exit when minutes >0 %exit condition for loop
%structure
end loop %ends nested loop structure
elsif minutes >59 then
loop %starts nested loop structure
locate (19,3)
put "Please enter a number between"..%prompts user to enter a
put "0 and 59 :".. %number between 0 and 59
get minutes %retrieves minutes
locate (18,3)
for i:2..35 %starts nested counted loop
put " "..
end for %ends nested counted loop
exit when minutes <=59 %exit condition for loop
%structure
end loop %ends nested loop
end if %ends if structure
locate (4,30)
put "Minutes parked " %displays words in quotes
locate (6,35)
put minutes %displays minutes
delay (1000)
locate (22,3)
put "You have parked your vehicle for ",
hours," hours and ", minutes ," minutes"
if minutes=0 then %starts if structure
minutes:=0
elsif minutes >30 and minutes <60 then
minutes :=60
elsif minutes <30 then
minutes:=30
end if %ends if structure
totalminutes:=(hours*60)+ minutes %formula used to calculate
%fee
if totalminutes=0 then
fee:=2 %starts if structure
elsif totalminutes <=30 then
fee:=2+0.5 %gives computer formula to
%calculate fee
elsif totalminutes >30 and totalminutes
<=360 then
fee:=2+0.5+((minutes-30)/30*0.35)+ %gives computer formula to
hours*2*0.35 %calculate fee
elsif totalminutes >360 then
fee:=2+0.5+(5.5*2*0.35)+
(minutes/30*0.25)+(hours-6)*2*0.25
end if %ends selection structure
delay (1000)
locate (4,55)
put "Amount due" %displays words in quotes
delay (500)
locate (6,50)
put fee:10:2 %displays fee rounded off to 2
%decimal places
locate (7,2)
put repeat(chr(196),75)
delay (500)
locate (9,3)
put "BREAKDOWN OF FEE" %displays words in quotes
delay (500)
locate (9,30)
put "Base: $2.00"delay (500)
totalfee:=0 %initializes totalfee
if totalminutes =0 then %starts if structures
delay (500)
totalfee:=fee
locate (12,30)
put "Total amount due:",fee:10:2
elsif totalminutes <=360 then
totalfee:=fee-2.5
locate (11,30)
put "First 1/2 hour: $0.50"
locate (12,30)
put "First ",hours..
put "hour(s): $ ", totalfee:10:2..
elsif totalminutes>360 then
delay (500)
totalfee:=fee-2.5-3.85
hours:=hours-6
delay (500)
locate (11,30)
put "First 1/2 hour: $0.50"
delay (500)
locate (12,30)
put "First 6 hours: $3.85"
delay (500)
locate (13,30)
put "Next ",hours," hour(s): $"..
locate (13,50)
put totalfee:10:2
end if %ends if structure
delay (500)
locate (15,15)
put "Your total amount comes to $",fee:10:2 %displays words in quotes rounded
%off to 2 decimal places
locate (16,2)
put repeat(chr(176),76)
locate (21,1)
delay (500)
locate (24,3)
put "Would you like to exit? Y/N? ".. %prompts user whether they want
%to continue or exit
get answer %retrieves answer
case answer of
label "Y","y","yes": %if answer is N or n, then
delay (500)
cls %clears screen
locate (1,25)
put "Printing Receipt..." %displays words in quotes
locate (2,25)
put "Please wait"
delay (2000)
locate (5,15)
put repeat (chr (176),35).. %displays character in brackets
%onto output screen
locate (8,20)
put "Don't forget your receipt!"
delay (500)
locate (12,25)
put "Have a nice day!"
locate (14,25)
put repeat (chr (177),15)..
locate (16,15)
put repeat (chr (176),35)..
exit %exits the program
label "N", "n","no": %if answer is Y or y, then resume
%with the objective of the
%repetition
cls %clears the screen
delay (500)
locate (2,25)
put "Welcome back!"
end case %stops repetition action
end loop %ends loop structure
%---------------------------------End of Program---------------------------- |