Computer Science Igcse Pre Release Task 2
Computer Science Igcse Pre Release Task 2
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
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
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
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
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
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