Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN C LANGUAGE PLEASE For a number of years, manufacturers of goods sold in U.S. and Canadian stores have put a bar code on each
IN C LANGUAGE PLEASE
For a number of years, manufacturers of goods sold in U.S. and Canadian stores have put a bar code on each product. This code, known as a Universal Product Code (UPC), identifies both the manufacturer and the product. Each bar code represents a 12 - digit number, which is usually printed beneath the bars. For example, the following bar code comes from Yogi Purely Peppermint Tea.
Peppermint Program 2 Description For a number of years, manufacturers of goods sold in U.S. and Canadian stores have put a bar code on each product. This code, known as a Universal Product Code (UPC), identifies both the manufacturer and the product. Each bar code represents a 12-digit number, which is usually printed beneath the bars. For example, the following bar code comes from Yogi Purely Peppermint Tea. Yogi Purely 0 769501450471119 The digits 0 76950 450479 appear underneath the bar code. The first digit identifies the type of item (0 or 7 for most items, 2 for items that must be weighted, 3 for dugs an health-related merchandise, and 5 for coupons). The first group of 5 digits identifies the manufacturer (76950 is the code for the Yogi company). The second group of 5 digits identifies the product (in this case Purely Peppermint Tea). The final digit is a "check digit", whose only purpose is to identify an error in the preceding digits. If the UPC is incorrectly scanned, the first 11 digits likely won't be consistent with the last digit, and the store's scanner will reject the entire code. The final "check digit" is calculated with the following steps: 1. Add the first, third, fifth, seventh, ninth, and eleventh digits. 2. Add the second, fourth, sixth, eigth, and tenth digits. 3. Multiply the first sum by 3 and add it to the second sum. 4. Subtract 1 from the total. 5. Compute the remainder when the adjusted total is divided by 10. 6. Subtract the remainder from 9. For the example UPC above: 1. First Sum = 0 + 6 +5+4 + 0 + 7 = 22 2. Second Sum = 7 + 9 + 0 + 5+ 4 = 25 3. Total = (22 * 3) + 25 = 66 + 25 = 91 4. Adjusted Total = 91 - 1 = 90 5. Remainder = 90 % 10 = 0 % is the modulus operator in C it divides the two numbers and gives the remainder) 6. Check Digit = 9-0 = 9 You need to write a program (named upc.c) that asks the user for a UPC and calculates the correct check digit. To avoid confusion, you will prompt (ask) the user to input the numbers in the groups they appear within on the barcodeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started