Nothing Special   »   [go: up one dir, main page]

Pre Release May 2021

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

Mr Nanda YENKETERAMDOO Goodlands SSS Pre_Release June May/June 2021 1

TASK 1

Qu1 Describe two variables that could be used in the tasks.

(a) DepartureTime
Use: to store the time of departure of a train to go to the top of the mountain.
For example 9:00, 11:00, 13:00 and 15:00
Data type: Integer

(b) ReturnTime
Use: to store the time a train return from the top of the mountain. For example
10:00, 12:00, 14:00 and
16:00 Data type: Integer (c)
TicketType
Use: to store the type of ticket purchased by customers. For example ‘S’
represents Single Ticket and ‘G’ represents Group Tickets Data type: Char
(d) NumofFreeTicket
Use: to hold the number of free tickets given to a group. For example
Minimum number of free tickets is 1 and the maximum is 8 Data type: Integer

Qu2 Describe a constant that could be used in the tasks.

Name: CostofJourney
Value: 25
Description: It is the cost for the journey up or down the mountain.
Name: MaxNumberSeat
Value: 480
Description: It is the maximum number of seat available per train except for the last
one returning from the top of the mountain.

Qu3 Describe three data structures that could be used in the tasks.
(a) TotalPassengers
Data structure: One dimensional array of size 8
Data Type: Integer
Description: Each element is the total number of people who have travelled in
the train.
For example its first element holds the total number of people who have
travelled at 9:00 and so on
Declaration: DIM TotalPassengers(8) as Integer (b)
TotalMoneyTaken
Data structure: One dimensional array of size 8
Data Type: Integer
Description: Each element is the total money taken for each journey
Mr Nanda YENKETERAMDOO Goodlands SSS Pre_Release June May/June 2021 2

For example TotalMoneyTaken(1) is 1000. This means Money received for


the journey 9:00
Declaration: DIM TotalMoneyTaken(8) as Integer
(c) NumSeatAvailable
Data structure: One dimensional array of size 8
Data Type: Integer
Description: Each element is the number of seat(s) available for each journey
For example NumSeatAvailable(2) is 70. This means that the number of seats
available for the journey 10:00 is 70
Declaration: DIM NumSeatAvailable (8) as Integer

Qu4 Write a program code to initialise the data structures you have mentioned above.

DIM TotalPassengers(8), TotalMoneyTaken(8), NumSeatAvailable (8) as Integer


DIM i as Integer

For I = 1 to 8
TotalPassengers(i) = 0
TotalMoneyTaken(i) = 0
Next

For I = 1 to 7
NumSeatAvailable(i) = 480
Next
NumSeatAvailable(8) = 640

Qu4 Write a program code to the screen

Console.writeline(“ Marie Louise Railway Station “)


Console.writeline(“ Welcomes You “)
Console.writeline(“Day Date: “)
Console.writeline(“--------------------------------------------------------------- “)
Console.writeline(“DEPARTURE INFORMTION “)
Console.writeline(“ Time Of Departure Number of Seats Available“)
Console.writeline(“ 9:00 “ & NumSeatAvailable(1))
Console.writeline(“ 10:00 “ & NumSeatAvailable(2))
Console.writeline(“ 11:00 “ & NumSeatAvailable(3))
Console.writeline(“ 12:00 “ & NumSeatAvailable(4))
Console.writeline(“ 13:00 “ & NumSeatAvailable(5))
Console.writeline(“ 14:00 “ & NumSeatAvailable(6))
Console.writeline(“ 15:00 “ & NumSeatAvailable(7))
Console.writeline(“ 16:00 “ & NumSeatAvailable(8))
Mr Nanda YENKETERAMDOO Goodlands SSS Pre_Release June May/June 2021 3

TASK 2
Dim DTime As Integer ‘Time of Departure
Dim RTime as integer ‘Time to return
Dim TicketType As Char ‘Type of ticket
Dim Numgroup as integer ‘Number of people in group
Dim num10 as integer ‘Quotient of Number of people in group divide by 10 Dim
discount as integer

Do
Console.WriteLine("Enter time to leave from the foot of the mountain")
DTime = Console.ReadLine
If Not ((DTime = 9) Or (DTime = 11) Or (DTime = 13) Or (DTime = 15)) Then
Console.WriteLine("ERROR !!! Invalid Time. TRY AGAIN")
End If
Loop Until (DTime = 9) Or (DTime = 11) Or (DTime = 13) Or (DTime = 15)
Do
Console.WriteLine("Enter time to leave from the top of the mountain")
RTime = Console.ReadLine

If Not ((RTime = 10) Or (RTime = 12) Or (RTime = 14) Or (RTime = 16)) Then
Console.WriteLine("ERROR !!! Invalid Time. TRY AGAIN")
End If
Loop Until ((RTime = 10) Or (RTime = 12) Or (RTime = 14) Or (RTime = 16))

Do
Console.WriteLine("Enter the type of ticket")
TicketType = Console.ReadLine
If Not ((UCase(TicketType) = "G") Or (UCase(TicketType) = "S")) Then
Console.WriteLine("ERROR! TRY AGAIN")
End If
Loop Until ((UCase(TicketType) = "G") Or (UCase(TicketType) = "S"))

IF TicketType = “S” Then


NumofSeatsAvailable(Dtime-8) = NumofSeatsAvailable(Dtime-8) -1
NumofSeatsAvailable(Rtime-8) = NumofSeatsAvailable(Rtime-8) -1
Totalpassengers(Dtime-8)= Totalpassengers(Dtime-8) + 1
Totalpassengers(Rtime-8)= Totalpassengers(Rtime-8) + 1
Totalmoneytaken(Dtime-8)= Totalmoneytaken(Dtime-8) + CostofJourney
Totalmoneytaken(Rtime-8)= Totalmoneytaken(Rtime-8) + CostofJourney
ELSE
Do
Console.writeline(“Please enter the number of people in the group”)
Numgroup = console.readline
If not (numgroup > = 10 and numgroup <= 80) then
Console.writeline(“Error!!!,Try again”)
End if
Loop until (numgroup > = 10 and numgroup <= 80)
If (numgroup > NumofSeatsAvailable(Dtime-8)) OR (numgroup > numofSeatsAvailable (Rtime-8)) Then
Console.writeline(“Error!!!,Try again”)
Else
Mr Nanda YENKETERAMDOO Goodlands SSS Pre_Release June May/June 2021 4

NumofSeatsAvailable(Dtime-8) = NumofSeatsAvailable(Dtime-8) - numgroup


numofSeatsAvailable(Rtime-8) = NumofSeatsAvailable(Rtime-8) - numgroup
Totalpassengers(Dtime-8)= Totalpassengers(Dtime-8) + numgroup
Totalpassengers(Rtime-8)= Totalpassengers(Rtime-8) + numgroup
Num10 = INT(numgroup/10)
Discount= num10 * 25
Totalmoneytaken(Dtime-8)= Totalmoneytaken(Dtime-8) + (numgroup*CostofJourney) -discount
Totalmoneytaken(Rtime-8)= Totalmoneytaken(Rtime-8) + (numgroup*CostofJourney) -discount
endif

Task3
Dim TotalPassengersDay, TotalMoneyTakenDay as integer
Dim HighestJourneyPassenger, i, JourneyNum as integer

TotalPassengersDay=0 TotalMoneyTakenDay=0
HighestJourneyPassenger=0

For i = 1 to 8
TotalPassengersDay= TotalPassengersDay + Totalpassengers(i)
TotalMoneyTakenDay= TotalMoneyTakenDay + Totalmoneytaken(i)
IF Totalpassengers(i) > HighestJourneyPassenger then
HighestJourneyPassenger = Totalpassengers(i)
JourneyNum = i
Endif
Next
Console.writeline(“The total number of passengers for the day is “ & TotalPassengersDay)
Console.writeline(“The total number of Money Taken for the day is “ & TotalMoneyTakenDay)
Console.writeline(“The highest number of passengers is “ & HighestJourneyPassenger & “in journey
“& Journeynum)

You might also like