Pseudo Code Computer Science Pre-release 2019

?
  • Created by: Leary103
  • Created on: 04-02-19 05:29

Task 1 Part 1

DECLARE amount : INTEGER

amount ← 0

 

WHILE amount < 10

    INPUT “Please enter the amount of auction items: “ amount

    IF amount < 10

        OUTPUT "The minimum value must be 10 or more."

    ENDIF

ENDWHILE

1 of 18

Task 1 Part 2

 

DECLARE item_numbers : ARRAY[0:amount] OF INTEGER

DECLARE descriptions : ARRAY[0:amount] OF STRING

DECLARE reserve_price : ARRAY[0:amount] OF REAL

DECLARE bid_numbers : ARRAY[0:amount] OF INTEGER

2 of 18

Task 2 Part 1

DECLARE buyers : ARRAY[0:amount] OF STRING

DECLARE recorded_bids : ARRAY[0:amount] OF INTEGER

3 of 18

Task 1 Part 3

DECLARE item_code : INTEGER

DECLARE item : STRING

DECLARE reserve : REAL

DECLARE no_of_bids : INTEGER

4 of 18

Task 2 Part 2

DECLARE answer : STRING

DECLARE search : INTEGER

DECLARE bid : REAL

DECLARE buyer_id : STRING

DECLARE found : BOOLEAN 

5 of 18

Task 3 Part 1

DECLARE fee : REAL

DECLARE total_fee : REAL

DECLARE total_sold : INTEGER

DECLARE total_no_reserve : INTEGER

DECLARE total_no_bids : INTEGER

6 of 18

Task 1 Part 4

item_code ← 0

item ← ""

reserve ← 0.0

no_of_bids ← 0

7 of 18

Task 2 Part 3

answer ← "" 

search ← 0 

bid ← 0.0 

buyer_id ← "" 

found ← False

8 of 18

Task 3 Part 2

fee ← 0.0 

total_fee ← 0.0 

total_sold ← 0 

total_no_reserve ← 0 

total_no_bids ← 0

9 of 18

Task 1 Part 5

FOR index ← 1 TO amount

    item_code = item_code + 1

    item_numbers[index] = item_code

    INPUT “Please enter your item description: “ item

    descriptions[index] = item

    INPUT "What is your reserve?: " reserve

    reserve_price[index] = reserve

    bid_numbers[index] = no_of_bids

10 of 18

Task 1 Part 6

 

    OUTPUT "Added item: ", item

    OUTPUT "Reserve price: ", reserve

    OUTPUT "Item number: ", item_code

 

ENDFOR

11 of 18

Task 2 Part 4

WHILE answer <> "end"

 

    INPUT “Enter item number: “ search  

     

    FOR index ← 1 TO amount:

        IF item_numbers[index] = search

            

            found ← True

 

12 of 18

Task 2 Part 5

 OUTPUT "You found: ", descriptions[index]

            OUTPUT “Highest current bid: ", recorded_bids[index]

            OUTPUT "Bidder: ", buyers[index] 

            OUTPUT “Number of bids: ", bid_numbers[index]

            INPUT "Please enter your buyer ID: " buyer_id

            INPUT "Please enter your bid: " bid

IF bid > recorded_bids[index]:                

     OUTPUT “You are currently the highest bidder!"

                 recorded_bids[index] = bid

                buyers[index] = buyer_id

                bid_numbers[index] = bid_numbers[index] + 1

13 of 18

Task 2 Part 6

                BREAK

            ELSE

                OUTPUT "Sorry, your bid is too low."

               BREAK

            ENDIF

        ELSE

            found ← False

        ENDIF

    

    ENDFOR

14 of 18

Task 2 Part 7

    IF found = False:

        OUTPUT "Sorry, could not find item."

    ENDIF

 

    OUTPUT "Would you like to make another bid?”

    INPUT “Type 'end' to end the auction " answer

 

ENDWHILE

15 of 18

Task 3 Part 3

FOR index ← 1 TO amount

    IF recorded_bids[index] >= reserve_price[index]

        fee ← recorded_bids[index] * 0.1

        total_fee ← total_fee + fee

        total_sold ← total_sold + 1

    ELSE 

        IF recorded_bids[index] < reserve_price[index] AND     

        bid_numbers[index] > 0

            OUTPUT "Item number", item_numbers[index], "did not 

            reach the reserve price of", reserve_price[index]

16 of 18

Task 3 Part 4

            OUTPUT "The highest bid was", recorded_bids[index]

        

            total_no_reserve ← total_no_reserve + 1

        

        ELSE

            

            OUTPUT "Item number", item_numbers[index], "did not 

            receive any bids."

            total_no_bids ← total_no_bids + 1

        

17 of 18

Task 3 Part 5

OUTPUT "The total items sold is", total_sold

 

OUTPUT "The total fee for all sold items is, ", total_fee

 

OUTPUT "The total items that did not meet the reserve price is", total_no_reserve

 

OUTPUT "The total items with no bids is", total_no_bids

18 of 18

Comments

No comments have yet been made

Similar Computing resources:

See all Computing resources »See all Pre Release resources »