0% found this document useful (0 votes)
65 views5 pages

Final Pre Release CS 2020

The document contains pseudocode for three tasks related to calculating parking prices. Task 1 calculates the price based on arrival time, hours parked, day of week and any discounts. Task 2 extends Task 1 to track a daily total of payments. Task 3 further extends Task 1 to calculate prices more fairly when the parking time spans before and after 4pm.

Uploaded by

Eman Gurmani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views5 pages

Final Pre Release CS 2020

The document contains pseudocode for three tasks related to calculating parking prices. Task 1 calculates the price based on arrival time, hours parked, day of week and any discounts. Task 2 extends Task 1 to track a daily total of payments. Task 3 further extends Task 1 to calculate prices more fairly when the parking time spans before and after 4pm.

Uploaded by

Eman Gurmani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Pre-Release Computer Science Solution 2020

Pseudocode of Task-1
TASK 1-Calculating the price to park.
A customer inputs the day, the hour of arrival excluding minutes (for example 15:45 would be 15), the
number of hours to leave their car, and a frequent parking number if available. If the frequent parking
number has an incorrect check digit, then no discount can be applied. The price to park, based on the day,
the hour of arrival, the number of hours of parking required and any discount available, is calculated and
displayed.

Variables:

DECLARE ArrivalTime, MaxStay, ParkTime, PricePerHour, ParkingPrice, Choice, FPN,


Remainder, Discount, MoneyPayable As INTEGER
Day=” ”
ArrivalTime=0
MaxStay=0
ParkTime=0
PricePerHour=0
ParkingPrice=0
Choice=0
FPN=0
Remainder=0
Discount=0
MoneyPayable=0

Constants:
Hour = (MidDay, MidNight)
Day= Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday

//Inputs for car Parking


INPUT “Enter Day=”, Day
REPEAT
OUTPUT “No Parking Available between Midnight (24) till before Morning (8)”
INPUT “Enter Arrival Time from 8 to 23 (Hours only) =”, ArrivalTime
UNTIL ArrivalTime>=8 AND ArrivalTime<24
//Time and Day selection and calculation of Parking Price
IF ArrivalTime>=8 AND ArrivalTime<16
THEN IF Day=”Monday” OR Day=“Tuesday” OR Day=”Wednesday” OR Day=”Thursday” OR
Day=”Friday”

THEN MaxStay=2
REPEAT
OUTPUT “Enter Park Time, You can Park for maximum 2 Hours”
INPUT “Enter Park Time=”, ParkTime
UNTIL ParkTime>0 AND ParkTime<= MaxStay

Zohaib
PricePerHour=10
ParkingPrice= PricePerHour * ParkTime
ELSEIF Day=”Sunday”
THEN MaxStay=8
REPEAT
OUTPUT “Enter Park Time, You can Park for maximum 8 Hours”
INPUT “Enter Park Time=”, ParkTime
UNTIL ParkTime>0 AND ParkTime <=MaxStay
PricePerHour=2
ParkingPrice= PricePerHour * ParkTime
ELSEIF Day=”Saturday”
THEN MaxStay=4
REPEAT
OUTPUT “Enter Park Time, You can Park for maximum 4 Hours”
INPUT “Enter Park Time=”, ParkTime
UNTIL ParkTime>0 AND ParkTime<= MaxStay
PricePerHour= 3
ParkingPrice= ParkingPrice * ParkTime
ENDIF
ELSEIF ArrivalTime>=16 AND ArrivalTime <24
ParkingPrice=2
ENDIF
//Choice for FPN
INPUT “Press=1 If you have FPN and Press=0 If you don’t have FPN”, Choice
//Validation of FPN
IF Choice=1
THEN INPUT “Please enter 5 Digit FPN”, FPN
Sum=0
FOR Position= 1 TO 5
Digit=FPN MOD 10
Sum=Sum + (Digit * Position)
FPN =FPN DIV 10
NEXT Position
Remainder =Sum MOD 11
Zohaib
// Calculation of Payable Money on Validation of PFN
IF ArrivalTime>=8 AND ArrivalTime<16
THEN IF Remainder<>0
THEN PRINT “Invalid FPN, No Discount”
MoneyPayable= ParkingPrice
ELSE PRINT “10% Discount available”
Discount= ParkingPrice * 0.1
MoneyPayable=ParkingPrice – Discount
ENDIF
ELSEIF ArrivalTime>=16 AND ArrivalTime<24
THEN IF Remainder<>0
THEN PRINT “Invalid FPN”, No Discount”
MoneyPayable= ParkingPrice
ELSE PRINT “50 % Discount available”
Discount= ParkingPrice * 0.5
MoneyPayable= ParkingPrice- Discount
ENDIF
ENDIF
//Time and Day selection without FPN
ELSEIF Choice=0
THEN OUTPUT “No Discount available without FPN”
IF ArrivalTime>8 AND ArrivalTime<16
THEN MoneyPayable= ParkingPrice
ELSEIF ArrivalTime>=16 AND ArrivalTime<24
THEN MoneyPayable= ParkingPrice
ENDIF
ENDIF
//Final Output
PRINT “Day=”, Day
PRINT “Price To Park=”, MoneyPayable
PRINT ”Hours of Parking=”, ParkTime
PRINT “Arrival Time=”, ArrivalTime

Zohaib
Pseudocode of Task-2

Task 2 – Keeping a total of the payments.


Extend Task 1 to keep a daily total of payments made for parking. The daily total is zeroed at the start of
the day. For the simulation, each customer inputs the amount paid, this must be greater than or equal to
the amount displayed. There is no change given so the amount input may exceed the amount displayed.
Each customer payment is added to the daily total, and this total is displayed at the end of the day.

Task-2 Keeping a Total of the Payments (Task-1 Extension)

Variables:
DECLARE CurrentTime As STRING
DECLARE DailyTotal, MoneyPaid As INTEGER

DailyTotal =0
MoneyPaid =0

CurrentTime=SystemTime()
IF CurrentTime == ”07:59”
THEN DailyTotal = 0
ELSEIF CurrentTime>= ”08:00” AND CurrentTime < “00:00”
THEN INPUT “Money Paid = ”, MoneyPaid
DailyTotal = DailyTotal + MoneyPaid
ELSEIF CurrentTime == “00:00”
THEN OUTPUT “Daily Total =”, DailyTotal
ENDIF

Pseudocode of Task-3
Task 3 – Making payments fairer.
Customers have complained that sometimes they are being charged too much if they arrive before
16:00 and depart after 16:00. Extend Task 1 to calculate the price before 16:00, then add the evening
charge. For example, a customer arriving at 14:45 on a Sunday and parking for five hours was previously
charged 10.00 and would now be charged 6.00

Task-3 Making Payments Fairer:

Variables:

DECLARE DepertureTime As STRING


DECLARE ParkTimeBefore16, MoneyPayableBefore16, MoneyPayableAfter16,
DiscountBefore16, DiscountAfter16, Discount As REAL

DepartureTime=ArrivalTime + ParkTime
IF DepartureTime>16
THEN ParkTimeBefore16 = 16 - ArrivalTime
MoneyPayableBefore16 = PricePerHour * ParkTimeBefore16
Zohaib
MoneyPayableAfter16 = 2
MoneyPayable = MoneyPayableBefore16 + MoneyPayablrAfter16
IF Remainder=0
THEN DiscountBefore16 = MoneyPayableBefore16 * 0.1
DiscountAfter16 = MoneyPayableAfter16 * 0.5
Discount = DiscountBefore16 + DiscountAfter16
MoneyPayable = = MoneyPayable – Discount
ENDIF
ENDIF

OUTPUT “Arrival Time = ”, ArrivalTime


OUTPUT “Park Time = ”, ParkTime
OUTPUT “Payable Money =”, MoneyPayable

Zohaib

You might also like