Log in with your CS lab user name and password so that you will be able to save any files you work on for later use. (On Windows, you will need to save your files to the T: drive to be able to use them later.)
"java -jar /Applications/MarieSim/marieSim.jar" is the command to run MARIE from the command line in the Mac OS; double-clicking on MarieSim.jar in a Mac Finder window will also start it. In Windows, open the Windows Explorer, go to "Computer", then the "Bootcamp" drive, then "Program Files", then "MarieSim" and double-click on marieSim.jar.
Write and run a complete MARIE assembly program to do this:
Read in and store 12 integers, each in the range 0-9 (inclusive) - the UPC code (the numbers at the bottom of a bar code) for some product Calculate the UPC check digit Output the check digit to the user
UPC codes (Universal Product Codes) are printed on many products in our daily lives. The numbers in the code are encoded into black and white bars and printed on the product packaging, for scanners to read. In every UPC code, the final (rightmost) digit is a "check digit," included to help prevent small errors in reading, copying and scanning.
The "check digit" in a UPC code is the 12th digit, printed to the right and slightly below the rightmost black bar.
For example, the UPC code on a pack of cards in my office is:
0 73854 60088 7 check = 0 + 3 + 5 + 6 + 0 + 8 = 22 check = 22 * 3 check = 66 + 7 + 8 + 4 + 0 + 8 = 93 check = 93 % 10 = 3 (93 modulus 10) check = 10 - 3 = 7, which is the check digit
MARIE does not have a division operation, so you may want to consider repeated subtraction.
A significant part of the grade for this lab will be determined by good programming style. Good programming style, in this case, will include carefully decomposing the problem into meaningful units of work, naming those units well, use of JnS to appropriately navigate around your source code, and, of course, clear, readable comments.
Every single line of code in your program must have a comment clearly explaining the purpose of that line. No exceptions. The comment on the top line of the source code file must include your first and last names. (Lines of source code specifying variable values should be commented appropriately, as well.)
Be careful to test your program on several real UPC codes. The professor has several items you may use if there are no bar codes on any items in your backpack.
Last updated 4/30/2015