You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this update, I have updated some prompts. In the previous solution, we asked the user to input Train Number but after reading the pre-release material again.
There it says, there is only one train that makes 4 return trips. So we shouldnt use "Train No: " in prompts and also shouldn't ask the user for "Train No" as an input.
To overcome this problem, I have changed the prompt "Train No: " to "Journey No: ". For example:
PRINT "Enter Journey number for your chosen departure hour: "
Update 2 Prompts Updated
The prompts that were too long or had unnecessary words have been updated as well and made short and understandable.
For example:
Before:
PRINT "Do you want to buy ticket(s)? 'True' for yes and 'False' for no"
PRINT "Enter 'True' for yes and 'False' for no: "
PRINT "Enter Train number corresponding to your departure hour: "
After:
PRINT "Do you want to buy ticket(s)? Enter True or False: "
"Invalid Input! Enter True or False: "
PRINT "Enter Journey number for your chosen departure hour: "
Update 3 Array starting index changed
Another update is, I have changed the starting index of the Arrays from 0 to 1. This is done because printing/saying "Journey No: 0" doesn't feel right and it would be easy for user to understand the counting starting from 1.
The declarations have been updated also. For example:
Before:
DECLARE UpTime : ARRAY[0:3] OF STRING
DECLARE UpSeats : ARRAY[0:3] OF INTEGER
DECLARE UpPassengers : ARRAY[0:3] OF INTEGER
DECLARE UpMoneyTotal : ARRAY[0:3] OF REAL
DECLARE DownTime : ARRAY[0:3] OF STRING
DECLARE DownSeats : ARRAY[0:3] OF INTEGER
DECLARE DownPassengers : ARRAY[0:3] OF INTEGER
DECLARE DownMoneyTotal : ARRAY[0:3] OF REAL
After:
DECLARE UpTime : ARRAY[1:4] OF STRING
DECLARE UpSeats : ARRAY[1:4] OF INTEGER
DECLARE UpPassengers : ARRAY[1:4] OF INTEGER
DECLARE UpMoneyTotal : ARRAY[1:4] OF REAL
DECLARE DownTime : ARRAY[1:4] OF STRING
DECLARE DownSeats : ARRAY[1:4] OF INTEGER
DECLARE DownPassengers : ARRAY[1:4] OF INTEGER
DECLARE DownMoneyTotal : ARRAY[1:4] OF REAL
All the FOR loops, WHILE loops and prompts have also been updated according to the new Array indexes. For example:
Before:
FOR index <- 0 TO 3
WHILE UpTrip < 0 OR UpTrip > 3 DO
PRINT "Error! Enter Journey number from (0, 1, 2, 3): "
WHILE DownTrip < UpTrip OR DownTrip > 3 DO
After:
FOR index <- 1 TO 4
WHILE UpTrip < 1 OR UpTrip > 4 DO
PRINT "Error! Enter Journey number from (1, 2, 3, 4): "
In python file all the changes mentioned above have been applied except Array index starting from 1.
Instead, I have done this:
I add 1 to the index in print statement so where it should be printing "Journey No: 0" it would now print "Journey No: 1".
This addition to the index in print statement does not effect the index variable being used in the loop.
for index in range(0, 4):
if UpSeats[index] != 0:
print("Journey No:", index + 1, "| Departure Hour:", UpTime[index], "\t| Tickets available:", UpSeats[index], )
else:
print("Journey No:", index + 1, "| Departure Hour:", UpTime[index], "| Closed!",)
if DownSeats[index] != 0:
print("Journey No:", index + 1, "| Return Hour:", DownTime[index], "\t| Tickets available:", DownSeats[index],)
else:
print("Journey No:", index + 1, "| Return Hour:", DownTime[index], "| Closed!")
Plus, regarding the input from user. The user is shown the counting starting from 1.
When he is asked for input he will enter a number from 1 to 4 but 1 will be subtracted from that number upon assigning it to the variable.
The validation also remains the same because of this.
For Example:
Ex#1
```
UpTrip = int(input("Enter Journey number for your chosen departure hour: ")) - 1
while UpTrip not in range(0, 4):
UpTrip = int(input("Error! Enter Journey number from (1, 2, 3, 4): ")) - 1
```
Ex#2
```
DownTrip = int(input("Enter Journey number for your chosen Return hour: ")) - 1
while DownTrip < UpTrip or DownTrip > 3:
DownTrip = int(input("Error! Enter Journey number from the given list above: ")) - 1
```
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
CHANGE 7: Big Update (Small change to the Algorithm and Prompts changes)
Date: 27/04/2021
Author: @Dunroxiz
commit: 105483a
Explanation:
Update 1: "Train No: " changed to "Journey No: "
In this update, I have updated some prompts. In the previous solution, we asked the user to input Train Number but after reading the pre-release material again.
There it says, there is only one train that makes 4 return trips. So we shouldnt use "Train No: " in prompts and also shouldn't ask the user for "Train No" as an input.
To overcome this problem, I have changed the prompt "Train No: " to "Journey No: ". For example:
Before:
PRINT ("Train No: ", index, "| Train Departure Hour: ", UpTime[index], "| Remaining Tickets: ", UpSeats[index])
PRINT "Enter Train number corresponding to your departure hour: "
After:
PRINT ("Journey No: ", index, "| Departure Hour: ", UpTime[index], "| Tickets available: ", UpSeats[index])
PRINT "Enter Journey number for your chosen departure hour: "
Update 2 Prompts Updated
The prompts that were too long or had unnecessary words have been updated as well and made short and understandable.
For example:
Before:
PRINT "Do you want to buy ticket(s)? 'True' for yes and 'False' for no"
PRINT "Enter 'True' for yes and 'False' for no: "
PRINT "Enter Train number corresponding to your departure hour: "
After:
PRINT "Do you want to buy ticket(s)? Enter True or False: "
"Invalid Input! Enter True or False: "
PRINT "Enter Journey number for your chosen departure hour: "
Update 3 Array starting index changed
Another update is, I have changed the starting index of the Arrays from 0 to 1. This is done because printing/saying "Journey No: 0" doesn't feel right and it would be easy for user to understand the counting starting from 1.
For example:
Before it would print:
After update it would now print:
The declarations have been updated also. For example:
Before:
After:
All the FOR loops, WHILE loops and prompts have also been updated according to the new Array indexes. For example:
Before:
FOR index <- 0 TO 3
WHILE UpTrip < 0 OR UpTrip > 3 DO
PRINT "Error! Enter Journey number from (0, 1, 2, 3): "
WHILE DownTrip < UpTrip OR DownTrip > 3 DO
After:
FOR index <- 1 TO 4
WHILE UpTrip < 1 OR UpTrip > 4 DO
PRINT "Error! Enter Journey number from (1, 2, 3, 4): "
WHILE DownTrip < UpTrip OR DownTrip > 4 DO
Update 4: New Print statement added
commit New Print Statement
A new print statement has been added that prints out the price of the two-way journey that user has booked for.
it only prints this if the seats have been booked.
PRINT "Total price for two-way journey: $", OneWayCost * 2,
Update 5: Python File Updated
commit: e4740c0
In python file all the changes mentioned above have been applied except Array index starting from 1.
Instead, I have done this:
I add 1 to the index in print statement so where it should be printing "Journey No: 0" it would now print "Journey No: 1".
This addition to the index in print statement does not effect the index variable being used in the loop.
Plus, regarding the input from user. The user is shown the counting starting from 1.
When he is asked for input he will enter a number from 1 to 4 but 1 will be subtracted from that number upon assigning it to the variable.
The validation also remains the same because of this.
For Example:
Ex#1
Ex#2
All files have been updated!
Beta Was this translation helpful? Give feedback.
All reactions