The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 2 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Checksum digit is an important error detection measure for integrity check for many codes, including UPC (Universal Product Code) barcodes. Typically, an UPC is a 12-digit number where the last digit on the right serves as the checksum digit. The checksum digit can be calculated based on other 11 digits of the UPC and if it does not match with the calculated value, it is certain that there is some error in the code transmission.
The checksum digit in a 12-digit UPC is calculated as follows:
Step 1: Sum of all digits at odd positions (counting from 1, left to right, 1, 3, 5, 7, 9, 11)
Step 2: Sum of all digits at even positions except the last position (counting from left to right, 2, 4, 8, 6, 10 – the 12th position is not included in the sum)
Step 3: Calculate (3*oddsum) + evensum
Step 4: If the result obtained at step 3 leaves remainder 0 when divided by 10, then checksum is 0. Otherwise, the checksum is (10 – the remainder when divided by 10).
Programming:
A sample file has been provided with the assignment description. The file contains 10 different UPCs. Write a Java program to check whether the UPC codes in the sample files are valid. If found invalid, indicate what would be the correct checksum digit (assuming there is no error in other 11 digits).
Program execution requirements:
1. The program must accept the input file as a command line argument. The test input file will have similar format as the sample file provided.
2. The output format should be indication of “valid” or “invalid” for each UPC on file. If “invalid”, the output should also indicate the correct checksum digit value. You do not need to write the output onto a file. Just display it on console.
Attachments:
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly