Giter VIP home page Giter VIP logo

pre-release-material-2021-p22-mj-cie's Introduction

  • ๐Ÿ‘‹ Hi, Iโ€™m @Dunroxiz
  • ๐ŸŒฑ Iโ€™m a Student, completing his A'Levels
  • ๐ŸŽฎ I like to play games (VALORANT).
  • ๐Ÿ’ป Also, I'm a self taught graphic designer.

pre-release-material-2021-p22-mj-cie's People

Contributors

dunroxiz avatar

Watchers

 avatar

pre-release-material-2021-p22-mj-cie's Issues

Making Task 1 more efficient

Before, The task 1 Train Journey Display algorithm had an IF statement in the FOR loop to check if the tickets were available or not. If tickets were not available it would PRINT that the Train for that hour is closed.

FOR index <- 0 TO 3
    IF UpSeats[index] != 0
        THEN
            PRINT ("Train No: ", index, "| Train Departure Hour: ", UpTime[index], "| Remaining Tickets: ", UpSeats[index])
        ELSE
            PRINT ("Train No: ", index, "| Train Departure Hour: ", UpTime[index], "| Closed!")
    ENDIF

    IF DownSeats[index] != 0
        THEN
            PRINT ("Train No: ", index, "| Train Return Hour: ", DownTime[index], "| Remaining Tickets: ", DownSeats[index])
        ELSE
            PRINT ("Train No: ", index, "| Train Return Hour: ", DownTime[index], "| Closed!")
    ENDIF
NEXT index

But knowing that this is the first time the Train Journey Display is being shown, and there had not been any bookings. We can remove the IF statements and the print statement for showing the Train is closed from the task 1 because there is no way that a train is going to be closed when the program has just started.

The improved algorithm for task 1 looks like this:

FOR index <- 0 TO 3
    PRINT ("Train No: ", index, "| Train Departure Hour: ", UpTime[index], "| Remaining Tickets: ", UpSeats[index])
    PRINT ("Train No: ", index, "| Train Return Hour: ", DownTime[index], "| Remaining Tickets: ", DownSeats[index])
    PRINT "---------"
NEXT index

link to the commit:
b6f69d8

Train Journey Display algorithm in Task 2 remain unchanged.

Originally posted by @Dunroxiz in #4

Error corrected in UpTrip Validation Loop Task 2

commit: f5d2ab5
There was a mistake in the condition of the WHILE loop that was being used as a validation for UpTrip.
AND have been changed to OR

All the files have been corrected and updated.

Before

    PRINT "Enter Train number corresponding to your departure hour: "
    INPUT UpTrip
    WHILE UpTrip < 0 AND UpTrip > 3 DO
        PRINT "Error! Enter train number from (0, 1, 2, 3): "
        INPUT UpTrip
    ENDWHILE

After:

    PRINT "Enter Train number corresponding to your departure hour: "
    INPUT UpTrip
    WHILE UpTrip < 0 OR UpTrip > 3 DO
        PRINT "Error! Enter train number from (0, 1, 2, 3): "
        INPUT UpTrip
    ENDWHILE

Keywords correction (No changes to the algorithm)

Link to the commit to see the changes 2b6748b

Before:
WHILE DownTrip < UpTrip OR DownTrip > 3:
WHILE NumOfPassengers <= 0:

After:
WHILE DownTrip < UpTrip OR DownTrip > 3 DO
WHILE NumOfPassengers <= 0 DO

All pseudocode files have been updated!

Keyword error in FOR loop corrected and Datatype changed for 2 variables in Task 3

commit 6e12d7b
Keyword error in FOR loop corrected in Task 3

Before:

FOR index <- 0 TO 3
    TotalPassengers <- TotalPassengers + UpPassengers[index]
    TotalAmount <- TotalAmount + (UpMoneyTotal[index] * 2)
ENDIF

After:

FOR index <- 0 TO 3
    TotalPassengers <- TotalPassengers + UpPassengers[index]
    TotalAmount <- TotalAmount + (UpMoneyTotal[index] * 2)
NEXT index

commit 2ff0acb
Datatype changed for 2 variables in Task 3
Datatype changed from REAL to INTEGER for TotalPassengers, MostPassengers.

Before:
DECLARE TotalPassengers, MostPassengers <- 0 : REAL

After:
DECLARE TotalPassengers, MostPassengers <- 0 : INTEGER

All pseudocode files have been updated

Updated the Pseudocode Files - Minor Mistakes

Hello Everyone,
I have updated the pseudocode files because they had some minor mistakes. There are no changes to the Algorithms itself.
There was just small a mistake in the last FOR loop.
Sorry for the inconvenience.

You can see the changes here:
204d2ef

Pseudocode Updated (prompts updated, array starting index changed and more)

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:

  1. PRINT ("Train No: ", index, "| Train Departure Hour: ", UpTime[index], "| Remaining Tickets: ", UpSeats[index])

  2. PRINT "Enter Train number corresponding to your departure hour: "

After:

  1. PRINT ("Journey No: ", index, "| Departure Hour: ", UpTime[index], "| Tickets available: ", UpSeats[index])

  2. 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:

  1. PRINT "Do you want to buy ticket(s)? 'True' for yes and 'False' for no"

  2. PRINT "Enter 'True' for yes and 'False' for no: "

  3. PRINT "Enter Train number corresponding to your departure hour: "

After:

  1. PRINT "Do you want to buy ticket(s)? Enter True or False: "

  2. "Invalid Input! Enter True or False: "

  3. 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:

PRINT ">>>>>    TRAIN JOURNEY DISPLAY    <<<<<"
FOR index <- 0 TO 3
    PRINT ("Journey No: ", index, "| Departure Hour: ", UpTime[index], "| Tickets available: ", UpSeats[index])
    PRINT ("Journey No: ", index, "| Return Hour: ", DownTime[index], "| Tickets available: ", DownSeats[index])
    PRINT "---------"
NEXT index


OUTPUT would be

Journey No: 0 | Departure Hour: 09:00 | Tickets available: 480
Journey No: 0 | Return Hour: 10:00 | Tickets available: 480
.......

After update it would now print:

PRINT ">>>>>    TRAIN JOURNEY DISPLAY    <<<<<"
FOR index <- 1 TO 4
    PRINT ("Journey No: ", index, "| Departure Hour: ", UpTime[index], "| Tickets available: ", UpSeats[index])
    PRINT ("Journey No: ", index, "| Return Hour: ", DownTime[index], "| Tickets available: ", DownSeats[index])
    PRINT "---------"
NEXT index


OUTPUT would be

Journey No: 1 | Departure Hour: 09:00 | Tickets available: 480
Journey No: 1 | Return Hour: 10:00 | Tickets available: 480
.......

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:

  1. FOR index <- 0 TO 3

  2. WHILE UpTrip < 0 OR UpTrip > 3 DO

  3. PRINT "Error! Enter Journey number from (0, 1, 2, 3): "

  4. WHILE DownTrip < UpTrip OR DownTrip > 3 DO

After:

  1. FOR index <- 1 TO 4

  2. WHILE UpTrip < 1 OR UpTrip > 4 DO

  3. PRINT "Error! Enter Journey number from (1, 2, 3, 4): "

  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.

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
```

All files have been updated!



Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.