PRM Solution 21

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Task-1: Pseudocode

UpTime=[“09:00”,”11:00”,”13:00”,”15:00”]
UpTicket=[480,480,480,480]
UpMoney=[0,0,0,0]

DownTime=[“10:00”,”12:00”,”14:00”,”16:00”]
DownTicket=[480,480,480,640]
DownMoney=[0,0,0,0]

FOR Count= 1 to 4
OUTPUT “ Timing, Availability of Tickets, Money Taken”
OUTPUT UpTime[Count],UpTicket[Count],UpMoney[Count]
OUTPUT DownTime[Count],DownTicket[Count],DownMoney[Count]
NEXT Count

Task 1 Output:

Md.Mehedi Hasan/ O and A Level Conputer Science Teacher/Contact: 01871511834 Page 1 of 4


Task-2: Pseudocode
INPUT “ Would you like to buy ticket (Yes/No)?”, Buy_Ticket
WHILE Buy_Ticket=”Yes” Do
INPUT” What time would you like to go up (09:00, 11:00, 13:00, 15:00)”, Utime
WHILE Utime<>”09:00” OR Utime<>”11:00” OR Utime<>”13:00” OR Utime<>”15:00” DO
OUTPUT “ Invalid Up time”
INPUT “ Enter the correct departure time”, Utime
END WHILE
FOR Count= 1 to 4
IF Utime=UpTime[Count] THEN
Up_Index=Count
END IF
NEXT Count
INPUT” What time would you like to go Down (10:00,12:00,14:00,16:00)”, Dtime
WHILE Dtime<>”10:00” OR Dtime<>”12:00” OR Dtime<>”14:00” OR Dtime<>”16:00” DO
OUTPUT “ Invalid Down time”
INPUT Enter the correct down time”, Dtime
END WHILE
FOR Count= 1 to 4
IF Dtime=DownTime[Count] THEN
Down_Index=Count
END IF
NEXT Count
INPUT “Enter the No of Ticket”, Ticket
WHILE Ticket>UpTicket[Up_Index] OR Ticket>80 OR Ticket<1 Do
Output “ No of up ticket is not vailable or Invalid No of Ticket”
INPUT “Enter the No of up Ticket”,Ticket
END WHILE
UpTicket[Up_Index]= UpTicket[Up_Index]-Ticket

WHILE Ticket>DownTicket[Down_Index] OR Ticket>80 OR Ticket<1 Do


Output “ No of down ticket is not vailable or Invalid No of Ticket”
INPUT “Enter the No of down Ticket”, Ticket
END WHILE
DownTicket[Down_Index]= DownTicket[Down_Index]-Ticket

Md.Mehedi Hasan/ O and A Level Conputer Science Teacher/Contact: 01871511834 Page 2 of 4


Discount= (Ticket DIV 10)*25

TripCost= Ticket*25-Discount
UpMoney[UP_Index]= UpMoney[UP_Index]+ TripCost
DownMoney[Down_Index]= DownMoney[Down_Index]+ TripCost

FOR Count= 1 to 4
IF UpTicket[Count]=0 THEN
OUTPUTUpTime[Count],”Closed”,UpMoney[Count]
ELSE
OUTPUT UpTime[Count],UpTicket[Count],UpMoney[Count]
END IF
IF DownTicket[Count]=0 THEN
OUTPUT DownTime[Count],”Closed”,DownMoney[Count]
ELSE
OUTPUT DownTime[Count], DownTicket[Count], DownMoney[Count]
END IF
NEXT Count
INPUT “Would you like to buy ticket (Yes/No)?”, Buy_Ticket
END WHILE

Md.Mehedi Hasan/ O and A Level Conputer Science Teacher/Contact: 01871511834 Page 3 of 4


Task-3 Pseudocode
Const_UpTicket=[480,480,480,480]
Const_DownTicket=[480,480,480,640]
Total_passenger=0
Total_money=0
Highest_Up=0
Highest_down=0
FOR Count= 1 to 4
Passenger_up[Count]=Const_UpTicket[Count] - UpTicket[Count]
Passenger_down[Count]= Const_DownTicket[Count] - DownTicket[Count]
OUTPUT “ Timing, Total Passenger, Total Money Taken”
OUTPUT UpTime[Count], Passenger_up[Count],UpMoney[Count]
OUTPUT DownTime[Count], Passenger_down[Count],DownMoney[Count]
Total_passenger= Total_passenger+ Passenger_up[Count]
Total_money= Total_money+Upmoney[Count]+ DownMoney[Count]
IF Passenger_up[Count]> Highest_Up THEN
Highest _Up_Index = Count
Highest_Up= Passenger_up[Count]
END IF
IF Passenger_down[Count]>Highest_down THEN
Highest _Down_Index=Count
Highest-down= Passenger_down[Count]
END IF
IF Passenger_down[Highest_Down_Index]> Passenger_Up[Highest_Up_Index] THEN
Highest= DownTime[Highest_Down_Index]
ELSE
Highest= UpTime [Highest_Up_Index]
END IF
NEXT Count
PRINT “ Total no of passenger in the trip on that day”, Total_passenger
PRINT “ Total money for the day”,Total_money
PRINT”Most passengers were carried by the train at ”, Highest

Md.Mehedi Hasan/ O and A Level Conputer Science Teacher/Contact: 01871511834 Page 4 of 4

You might also like