Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have Assigment and I can't solve it could you pleas help me

Each item in a supermarket is identified by its Universal Product Code (UPC), which consists of a sequence of 12 digits appearing below a rectangle of bars. See Figure 8.13. The bars have these digits encoded in them so that the UPC can be read by an optical scanner. Let's refer to the UPC as d1 -d2 d3 d4 d5 d6 -d7 d8 d9 d10 d11 -d12. The single digit on the left, identifies the type of product (for instance, 0 for general groceries, 2 for meat and produce, 3 for drug and health products, and 5 for coupons). The first set of five digits, d2 d3 d4 d5 d6, identifies the manufacturer, and the second set of five digits, d7 d8 d9 d10 d11, identifies the product. The twelfth digit on the right, d12, is a check digit. It is chosen so that

--------------------------------------------------------------------------------
[Page 459]
3 · d1 + d2 + 3 · d3 + d4 + 3 · d5 + d6 + 3 · d7 + d8 + 3 · d9 + d10 + 3 · d11 + d12.
(*)



is a multiple of 10. For instance, for the UPC in Figure 8.11,
3 · 0 + 7 + 3 · 0 + 7 + 3 · 3 + 4 + 3 · 0 + 0 + 3 · 9 + 0 · 0 + 3 · 3 + 4 = 40.

Figure 8.13. A Universal Product Code.


Since 40 = 4 · 10, 40 is a multiple of 10. In the event that the cashier has to enter the UPC manually and mistypes a digit, the above sum will usually not add up to a multiple of 10.
Write a program to simulate an automated check-out counter at a supermarket. A master sequential file, called UPC.TXT, should have a record for each item consisting of fields for the UPC, name of the item, and the price of the item. For instance, the file might contain the following record:
070734000034
Celestial Seasons Sleepytime Tea
2.59

The file should be ordered with respect to the UPCs. The program should allow the cashier to enter UPCs one at a time, should keep a running total of the number of items processed, and should place the UPCs in an array. Each UPC should be checked with the sum (*) as soon as it is entered and should be reentered if the sum is not a multiple of 10. After all items have been processed, the program should sort the array of UPCs and then produce a receipt similar to the one in Figure 8.14 after making just one pass through the master sequential file.

Figure 8.14. Sample output of Programming Project 10.
Posted
Updated 15-Apr-10 11:35am
v2

What have you tried?

This whole point of this forum is not to supply you with solutions to your assignments but to help people out with specific problems.

If you don't even know where to start you should talk to your teacher.
 
Share this answer
 
What you have shown us is the assignment, but there nothing specified as to what you want help with.

If the gist, as I am reading it, is confirm a check digit is correct, you will have to create a modulus value to check against the check digit.

Not knowing how much VB you know, it would be worth looking at this[^] to give you the function of a modulus.

Perform the maths funtion described in the assignment and compare it to the modulus of the operation and if they fail to match then run the exception code.

The other way is to perform the calculations of the hoof.

I wrote a similar function for verifying VAT numbers.

Example code for VAT checking.

<pre lang="vb">' declare variable
        Dim strVatNumber As String
        Dim arrVatNumber(8) As Integer
        Dim intVatTotal As Integer
        Dim intCheckSum As Integer
        Dim strMessage
        ' set initial values
        strVatNumber = TextBox1.Text
        intVatTotal = 0
        ' loop to fill array from string and do the maths.
        For i = 0 To 6
            arrVatNumber(i) = Val(strVatNumber(i))
            arrVatNumber(i) = arrVatNumber(i) * (8 - i)
            intVatTotal = intVatTotal + arrVatNumber(i)
        Next
        ' assign check sum
        ' assure that no multiply by zero
        If arrVatNumber(7) <> 0 Then
            arrVatNumber(7) = Val(strVatNumber(7))
            arrVatNumber(8) = Val(strVatNumber(8))
            intCheckSum = (arrVatNumber(7) * 10) + arrVatNumber(8)
        Else
            intCheckSum = arrVatNumber(8)
        End If

        While intVatTotal > 97
            intVatTotal = intVatTotal - 97
        End While
        'give result
        If intCheckSum = intVatTotal Then
            strMessage = "Vat Number Confirmed OK"
        Else
            strMessage = "Vat Number -INCORRECT-"
        End If
        Label1.Text = strMessage




I assigned this to a button click event of a form.

Try either approach, good luck.
 
Share this answer
 
Nobody will do your homework for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900