Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 27 (Programming in FORTRAN) Most items sold in stores can be identified by a 12 digit Universal Product Code (UPC). In order to reduce

Question 27 (Programming in FORTRAN)

Most items sold in stores can be identified by a 12 digit Universal Product Code (UPC). In order to reduce scanning errors, the final digit of this code is a check digit. It is computed as follows (the algorithm is taken from http://en.wikipedia.org/wiki/Check_digit)

Add the digits (up to but not including the check digit) in the odd-numbered positions (first, third, fifth, etc.) together and multiply by three.

Add the digits (up to but not including the check digit) in the even-numbered positions (second, fourth, sixth, etc.) to the result.

Take the remainder of the result divided by 10 (modulo operation) and subtract this from 10 to derive the check digit.

For instance, the UPC barcode for a box of tissues is "036000241457". The last digit is the check digit "7", and if the other numbers are correct then the check digit calculation must produce 7.

Add the odd number digits: 0+6+0+2+1+5 = 14

Multiply the result by 3: 14 3 = 42

Add the even number digits: 3+0+0+4+4 = 11

Add the two results together: 42 + 11 = 53

To calculate the check digit, take the remainder of (53 / 10), which is also known as (53 modulo 10), and subtract from 10. Therefore, the check digit value is 7.

Write a Fortran program that reads a 12 digit UPC of the form 036000241457 and determines whether the code is valid or not. It will output a message Valid Code if the check digit is correct and Invalid Code if the check digit is incorrect. Note that the input has no spaces between the digits.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

Q.No.1 Explain Large scale map ? Q.No.2 Explain small scale map ?

Answered: 1 week ago

Question

=+Where does the focus of labor relations lie? Is it collective

Answered: 1 week ago

Question

=+With whom does the firm have to negotiate?

Answered: 1 week ago