|
CSci 152: Computer Programming II |
|
Fall 2004 |


|
Programming Assignment #1 |
|
The solution given here shows an example of how one might go about writing a C++ program that satisfies all of the requirements of assignment #1 and runs correctly. In this solution I have shown the declaration of several function, passing parameters to the functions by value and by reference, using arrays as parameters, and returning values from functions which are used in the main program.
Take note of the programming style of the suggested solution. Most of the guidelines from the CPP style guidelines document have been followed and you may see examples of them here.
I have also added a few things not asked for in the assignment. The extra credit was implemented, as well as a way to check that the entered barcode not only contains only valid digits, but also is of the correct length.
Barcode.cpp – An example solution for Assignment #1. We break the processing of a barcode into several functions to read in the barcode, convert the barcode character array to an integer array, do step one of the parity check by summing the odd digs, step 2 the multiplication of the even digits, and a function to check the calculated parity bit against the actual one received.
|
|
Programming Assignment #1 example solution |
Example Solution |
