0% found this document useful (0 votes)
116 views

Computer Science Igcse Pre Release Task 2

We have used a two dimensional array called Sale_Items to store the data related to sale items. The array has 6 columns to store Item ID, Description, Initial Bid Price, Number of Bids, Highest Bid Price and Buyer ID of highest bid. To record the number of bids for each item, we have used the 5th column of Sale_Items array. Each time a new valid bid is placed for an item, we increment the value at Sale_Items(item_index, 4) by 1. This keeps track of the number of bids received for that particular item. For example, if item with ID 101 has received 3 bids so far, the value stored at Sale_Items(item_index

Uploaded by

Hasnain Ajaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views

Computer Science Igcse Pre Release Task 2

We have used a two dimensional array called Sale_Items to store the data related to sale items. The array has 6 columns to store Item ID, Description, Initial Bid Price, Number of Bids, Highest Bid Price and Buyer ID of highest bid. To record the number of bids for each item, we have used the 5th column of Sale_Items array. Each time a new valid bid is placed for an item, we increment the value at Sale_Items(item_index, 4) by 1. This keeps track of the number of bids received for that particular item. For example, if item with ID 101 has received 3 bids so far, the value stored at Sale_Items(item_index

Uploaded by

Hasnain Ajaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Pre – Release Material MJ-2019 Teacher’s Name: Akhtab Hussain

Pre – Release Material May/June 2019


Task 2
Work Sheet # 1

Name of Student _______________ Class ______


Subject _______________________ Date _______
1. Describe with the aid of some sample data, the data structure that you have used to record the
data for the buyer’s ID in Task 2. [2]
Ans. We have used one dimensional array to store buyer’s ID. We have assumed that total numbers of
buyers are known in advance. Our solution will prompt the user to enter total number of buyers
using the following statement.
TotalBuyers = console.readline( )
We asked the user to enter the buyers’ id and store it in the array. We have used For loop to fill
the array.
For Buyer_Count = 1 to TotalBuyers
BuyerID(Buyer_Count) = console.readline( )
Next Buyer_Count
Sample Data

123
124
125
126

2. Explain how your program for Task 2 displays the data for sale items of the auction.
Programming statements used in your solution must be explained. Assume that Task 1 is
complete.
Ans. ______________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
Pre – Release Material MJ-2019 Teacher’s Name: Akhtab Hussain

____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
_________________________________________________________________________________ [4]
Pre – Release Material May/June 2019
Task 2
Work Sheet # 2

Name of Student _______________ Class ______


Subject _______________________ Date _______
1. Write an algorithm, in form of pseudocode AND flowchart, to display item number, description
and highest bid of the items to be sold. Also write program for the above problem.

Pseudocode:

Found = 0
Print “Enter Sale Item’s ID to search”
Input Search_ID
For count = 1 to Total_Items
If Search_ID = Sale_Items(count,1) Then
Found = 1
Print “Item ID = ”, Sale_Items(count,1)
Print “Description = ”, Sale_Items(count,2)
Print “Highest Bid = ”, Sale_Items(count,5)
End if
Next Count
If found = 0 Then
Print “ID Not Found”
End If
Pre – Release Material MJ-2019 Teacher’s Name: Akhtab Hussain

Program:

Module Module 1
Sub Main ( )
Dim found, search_ID, Total_Items as Integer
found = 0
Console.WriteLine("Enter Sale Item's ID to search")
search_ID = Console.ReadLine
For count = 1 To total_items
If search_ID = Sale_Item(count, 1) Then
found = 1
Console.WriteLine("Item ID = {0}", Sale_Item(count, 1))
Console.WriteLine("Description of Item : {0},", Sale_Item(count, 2))
Console.WriteLine("Maximum Bid for the Item = {0}", Sale_Item(count, 5))
Next Count
If found = 0 Then
Console.WriteLine("ID Not found")
Console.ReadLine()
End If
Console.ReadKey( )
End Sub
End Module

Pre – Release Material May/June 2019


Task 2
Work Sheet # 3

Name of Student _______________ Class ______


Subject _______________________ Date _______

1. Describe how your solution will ensure that the buyer’s id used in Task 2 is unique. Any
programming statement used in your answer must be fully explained.

Ans. ______________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
Pre – Release Material MJ-2019 Teacher’s Name: Akhtab Hussain

____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
_________________________________________________________________________________ [2]
2. Write an algorithm, in form of pseudocode AND flowchart using Task 2 to validate the bid of
the buyer. Also write program for the above problem.
Pseudocode:
x=1
While x > 0
found = 0
Print "Enter Sale Item's ID to search"
Input search_ID
For count = 1 To total_items
If search_ID = Sale_Item(count, 1) Then
found = 1
Print ("Item ID = ", Sale_Item(count, 1))
Print ("Description of Item : ", Sale_Item(count, 2))
Print ("Maximum Bid for the Item = ", Sale_Item(count, 5))
Print ("Do you want to bid for the item. Enter Y for Yes. Enter any other character to
skip.")
Input choice
If choice = "y" Then
Print ("Enter Your Bid")
Input bid
If bid > Sale_Item(count, 5) Then
Sale_Item(count, 5) = bid
Sale_Item(count, 4) = Sale_Item(count, 4) + 1
Print ("Buyer's ID = ", Buyer_ID(count))
Print ("Your bid is ", bid)
Console.ReadKey( )
Else
Print ("Please enter the bid which is higher then previous ones.")
End If
Else Exit For
End If
End If
Next
Pre – Release Material MJ-2019 Teacher’s Name: Akhtab Hussain

Program
Dim search_ID As Integer
Dim x As Integer
Dim found As Integer
Dim choice As Char
Dim bid As Integer
x=1
While x > 0
found = 0
Console.WriteLine("Enter Sale Item's ID to search")
search_ID = Console.ReadLine
For count = 1 To total_items
If search_ID = Sale_Item(count, 1) Then
found = 1
Console.WriteLine("Item ID = {0}", Sale_Item(count, 1))
Console.WriteLine("Description of Item : {0},", Sale_Item(count, 2))
Console.WriteLine("Maximum Bid for the Item = {0}", Sale_Item(count, 5))
Console.ReadKey()
Console.WriteLine("Do you want to bid for the item. Enter Y for Yes. Enter any other
character to skip.")
choice = Console.ReadLine
If choice = "y" Then
Console.WriteLine("Enter Your Bid")
bid = Console.ReadLine
If bid > Sale_Item(count, 5) Then
Sale_Item(count, 5) = bid
Sale_Item(count, 4) = Sale_Item(count, 4) + 1
Console.WriteLine("Your bid is {0}", bid)
Console.ReadKey()
Else
Console.WriteLine("Please enter the bid which is higher then previous ones.")
End If
Else
Exit For
End If
End If
Next
Pre – Release Material MJ-2019 Teacher’s Name: Akhtab Hussain

Pre – Release Material May/June 2019


Task 2
Work Sheet # 4

Name of Student _______________ Class ______


Subject _______________________ Date _______
1. Describe how your solution will record the number of bids for each item in Task 2. Any
programming statement used in your answer must be fully explained.

Ans. ______________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
_________________________________________________________________________________ [2]
2. Write an algorithm, in form of pseudocode AND flowchart, using Task 2 to record the number
of bids for each item. Also write program for the above problem.
Pseudocode:
For count = 1 to Total_Items
Print "Enter Your Bid"
bid = Console.ReadLine
If bid > Sale_Item(count, 5) Then
Sale_Item(count, 5) = bid
Sale_Item(count, 4) = Sale_Item(count, 4) + 1
Print ("Your bid is ", bid)
Else
Print "Please enter the bid which is higher then previous ones."
End If
Next count
Pre – Release Material MJ-2019 Teacher’s Name: Akhtab Hussain

Program

For count = 1 to Total_Items


Console.WriteLine("Enter Your Bid")
bid = Console.ReadLine
If bid > Sale_Item(count, 5) Then
Sale_Item(count, 5) = bid
Sale_Item(count, 4) = Sale_Item(count, 4) + 1
Console.WriteLine("Your bid is {0}", bid)
Console.ReadKey()
Else
Console.WriteLine("Please enter the bid which is higher then previous ones.")
End If
Next Count

Pre – Release Material May/June 2019


Task 2
Work Sheet # 5

Name of Student _______________ Class ______


Subject _______________________ Date _______
1. Describe how your solution will ensure that the buyer’s can bid for any item for any number of
times. Any programming statement used in your answer must be fully explained.

Ans. ______________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
_________________________________________________________________________________ [2]
Pre – Release Material MJ-2019 Teacher’s Name: Akhtab Hussain

2. Write an algorithm, in form of pseudocode AND flowchart, for Task 2. Also write program for
the above problem.
Pseudocode:
Print "enter number of buyers"
Input total_buyers
For buyer_count = 1 to total_buyers
Print "Enter Buyer's ID"
Input Buyer_ID(buyer_count)
***********************************************************************************
To check the uniquness of Buyer’s ID
***********************************************************************************
j=0
For i = 1 To buyer_count
If Buyer_ID(buyer_count) = Buyer_ID(i) Then
j=j+1
End If
Next
If j > 1 Then
Print "ID Already exists"
buyer_count = buyer_count - 1
Continue for
End If
***********************************************************************************
***********************************************************************************
x=1
While x > 0
***********************************************************************************
To Search a particular Sale Item and display its ID, description and Highest Bid
***********************************************************************************
found = 0
Print "Enter Sale Item's ID to search"
Input search_ID
For count = 1 To total_items
If search_ID = Sale_Item(count, 1) Then
found = 1
Print "Item ID = ", Sale_Item(count, 1)
Print "Description of Item : ", Sale_Item(count, 2)
Print "Maximum Bid for the Item = ", Sale_Item(count, 5)
***********************************************************************************
Pre – Release Material MJ-2019 Teacher’s Name: Akhtab Hussain

***********************************************************************************
Enter Buyer's information
***********************************************************************************
Print "Do you want to bid for the item. Enter Y for Yes. Enter any other character to
skip."
Input choice
If choice = "y" Then
Print Buyer_ID(buyer_count)
Print "Enter Your Bid"
Input bid
***********************************************************************************
To verift that the bid eneterd is higher than the previous one and record the number of bids
***********************************************************************************
If bid > Sale_Item(count, 5) Then
Sale_Item(count, 5) = bid
Sale_Item(count, 4) = Sale_Item(count, 4) + 1
Print ("Buyer's ID = ", Buyer_ID(buyer_count)
Print "Your bid is ", bid
Else
Print "Please enter the bid which is higher then previous ones."
End If
Else
Exit For
End If
End If
Next
***********************************************************************************
If found = 0 Then
Print "ID Not found"
End If
Console.WriteLine("Do you want to bid for more items? Enter Negative Number to Exit")
x = Console.ReadLine
End While
Next Buyer_count
Pre – Release Material MJ-2019 Teacher’s Name: Akhtab Hussain

Program:
Dim search_ID As Integer
Dim x As Integer
Dim found As Integer
Dim choice As Char
Dim total_buyers As Integer
Dim bid As Integer

'**************** Buyer can find an item and see information ***************


'****************************************************************************
Console.WriteLine("enter number of buyers")
total_buyers = Console.ReadLine
Dim Buyer_ID(total_buyers) As Integer
For buyer_count = 1 to total_buyers
Console.WriteLine("Enter Buyer's ID")
Buyer_ID(buyer_count) = Console.ReadLine
j=0
For i = 1 To buyer_count
If Buyer_ID(buyer_count) = Buyer_ID(i) Then
j=j+1
End If
Next
If j > 1 Then
Console.WriteLine("ID Already exists")
Continue While
End If
x=1
While x > 0
found = 0
Console.WriteLine("Enter Sale Item's ID to search")
search_ID = Console.ReadLine
For count = 1 To total_items
If search_ID = Sale_Item(count, 1) Then
found = 1
Console.WriteLine("Item ID = {0}", Sale_Item(count, 1))
Console.WriteLine("Description of Item : {0},", Sale_Item(count, 2))
Console.WriteLine("Maximum Bid for the Item = {0}", Sale_Item(count, 5))
Console.ReadKey()
'************************ Enter Buyer's information**************************
'****************************************************************************
Pre – Release Material MJ-2019 Teacher’s Name: Akhtab Hussain

Console.WriteLine("Do you want to bid for the item. Enter Y for Yes. Enter any other
character to skip.")
choice = Console.ReadLine
If choice = "y" Then
Console.WriteLine(Buyer_ID(buyer_count))
Console.WriteLine("Enter Your Bid")
bid = Console.ReadLine
‘******** To check whether the bid is larger then previous bids *************
'****************************************************************************
If bid > Sale_Item(count, 5) Then
Sale_Item(count, 5) = bid
Sale_Item(count, 4) = Sale_Item(count, 4) + 1
Console.WriteLine("Buyer's ID = {0}", Buyer_ID(buyer_count))
Console.WriteLine("Your bid is {0}", bid)
Console.ReadKey()
Else
Console.WriteLine("Please enter the bid which is higher then previous ones.")
End If
Else
Exit For
End If
End If
Next

If found = 0 Then
Console.WriteLine("ID Not found")
Console.ReadLine()
End If
Console.WriteLine("Do you want to bid for more items? Enter Negative Number to Exit")
x = Console.ReadLine
End While
Next Buyer_Count

You might also like