Вы находитесь на странице: 1из 5

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

1. Describe with the aid of some sample data, the data structure that you have used to record
the data for the sale items in Task 1.
Ans. We have used Two – Dimensional Array to the record the information for sale items in Task 1.
Every column of the array stores different type of data therefore we didn’t assign any type to the
array. VB Dot Net provides the features to assign the data type automatically according to input
value.
Sample Data:
124 Laptop 500 0
125 Music Player 200 0
126 Smart Phone 400 0
In this array we have used 4 columns for Task 1. First column records the ID of sale item.
Second column records the description of sale item. Third column records the reserve price and
Fourth column is used to store the number of bids which is initially set to Zero.
2. Explain how your program for Task 1 records the data for sale items of the auction.
Programming statements used in your solution must be explained.
Ans. Initially we prompt the user to enter total number of sale items using input statement i.e.
Total_Items = Console.Writeline ( )
We have used Two – Dimensional array to record the information of sale items in Task 1. We
filled the array using For Loop i.e.
For Count = 1 to Total_Items
Body of the loop contains three input statements to store ID, Description and Reserve price of
the sale item in 1st, 2nd and 3rd column of array respectively. We have also set the value of number
of bids to zero by using assignment statement in For loop i.e.
Sale_Items(count,4 ) = 0
3. Describe the suitable validation rules for Task 1.
Ans. Two validation rules are required in Task 1.
i. Number of sale items must be at least 10 otherwise auctions will not take place.
If Total_Items < 10 Then
Print “Auction cannot take place”
ii. Sale item should have a unique ID
If Search_ID = Sale_Items (count,1) Then
Print “ID already Exist”
Pre – Release Material MJ 2019 Teacher’s Name: Akhtab Hussain

4. Write an algorithm, in form of pseudocode AND flowchart, to record item number,


description and reserve price of the items to be sold. The number of bids must be set to
zero. There must be at least 10 items in the auction. Also write program for the above
problem.

Pseudocode:
Print "Enter Number of items"
Total_Items = Console.ReadLine
If total_items >= 10
Then
For count = 1 To total_items
Print "Enter Item Number"
Input Sale_Item(count, 1)
Print "Enter description of item"
Input Sale_Item(count, 2)
Print “Enter Reserve Price"
Input Sale_Item(count, 3)
Sale_Item(count, 4) = 0
Next Count
Else Print “Auction cannot Take place”
End If
Program:
Module Module1
Sub Main ( )
Console.WriteLine ("Enter Number of items")
Total_Items = Console.ReadLine
Dim Sale_Item(total_items, 6)
If total_items >=10 Then
For count = 1 To total_items
Console.WriteLine("Enter Item Number")
Sale_Item(count, 1) = Console.ReadLine
Console.WriteLine("Enter description of item")
Sale_Item(count, 2) = Console.ReadLine
Console.WriteLine("Enter Reserve Price")
Sale_Item(count, 3) = Console.ReadLine
Sale_Item(count, 4) = 0
Next count
Else
Console.WriteLine("Auction cannot take place")
Console.ReadKey ( )
End If
Pre – Release Material MJ 2019 Teacher’s Name: Akhtab Hussain

5. Describe how your solution will ensure that the sale item’s number used in Task 1 is unique.
Any programming statement used in your answer must be fully explained.
Ans. We have stored the sale item’s number in first column of a 2 dimensional array. To identify
whether the item number entered by user is unique, we compared it with the first column of the
array including itself. If the value matches with the stored IDs more than once, the input is
rejected.
J = 0 // it is used to count the number of matches found
For Count = 1 to Total_Items
Console.Writeline (“Enter ID”)
Input Search_ID
J=0
For i = 1 to Count
If Search_ID = Sale_Items(Count,1) Then
J=J+1
End If
Next i
If J > 1 Then
Console.Writeline (“ID already exists”)
Count = Count – 1
Continue For
End If
Sale_Items (Count,1) = Search_ID
Next Count

6. Write an algorithm, in form of pseudocode AND flowchart, for Task 1. Also write program
for the TASK 1.
Pseudocode:
Print "Enter Number of items"
Total_Items = Console.ReadLine
If total_items >= 10
Then
For count = 1 To total_items
Print "Enter Item Number"
J=0
Input Search_ID
For i = 1 to Count
If Search_ID = Sale_Items(Count,1) Then
J=J+1
End If
Next i
If J > 1 Then
Print “ID already exists”
Count = Count – 1
Pre – Release Material MJ 2019 Teacher’s Name: Akhtab Hussain

End If
Sale_Items (Count, 1) = Search_ID
Print "Enter description of item"
Input Sale_Item(count, 2)
Print “Enter Reserve Price"
Input Sale_Item(count, 3)
Sale_Item(count, 4) = 0
Next Count
Else
Print “Auction cannot Take place”
End If
Program

Module Module1
Sub Main( )
Dim total_items, j As Integer
Console.WriteLine("Enter Number of items")
total_items = Console.ReadLine
Dim Sale_Item(total_items, 4)
If total_items > 10
Then
For count = 1 To total_items
Console.WriteLine("Enter Item Number")
Sale_Item(count, 1) = Console.ReadLine
j=0
For i = 1 To count
If Sale_Item(count, 1) = Sale_Item(i, 1) Then
j=j+1
End If
Next
If j > 1 Then
Console.WriteLine("ID Already exists")
Count = count - 1
Continue For
End If
Console.WriteLine("Enter description of item")
Sale_Item(count, 2) = Console.ReadLine
Console.WriteLine("Enter Reserve Price")
Sale_Item(count, 3) = Console.ReadLine
Sale_Item(count, 4) = 0 ' Number of Bids
Pre – Release Material MJ 2019 Teacher’s Name: Akhtab Hussain

Next
Else
Print “Auction Cannot Take place”
End If
Console.ReadKey()
End Sub
End Module

Вам также может понравиться