Question
The Universal Product Code (UPC) on most grocery items contains a zero that is printed to the left of the bar code and 10 digits
The Universal Product Code (UPC) on most grocery items contains a zero that is printed
to the left of the bar code and 10 digits that are printed in two groups of five each below
the code. The first five digits represent a manufacturer and the second five digits represent
a specific product. To the right of the bar code, a check digit is printed. Write a
program that allows the user to enter the five-digit manufacturer code, the five-digit
product code, and the check digit. Display the result of a Boolean comparison (0 or 1)
that shows whether the check digit is correct according to the following algorithm.
(Hint: Use a combination of modulus, multiplication, and subtraction to separate the
digits in the entered code.)
a. Sum the second and fourth numbers in the manufacturer code.
b. Sum the first, third, and fifth numbers in the product code.
c. Sum the results of step a and step b, and multiply the total by 3.
d. Sum the first, third, and fifth numbers in the manufacturer code.
e. Sum the second and fourth digits in the product code.
f. Sum the results of steps d and e and add to the result from step c.
g. Take the remainder when the result of step f is divided by 10.
h. Subtract the result of step g from 10. Compare this result to the check digit entered by the
user. If the result and check digit are equal (if the Boolean value of the comparison is 1),
then the UPC is a valid one.
Your solution should prompt the user for the UPC numbers.
Your solution should report to the user if the UPC code in valid or not.
The user should be able to enter multiple tests.
The program must be programmed in c++
Step 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