Quote
I am a student who does not feel like doing his homework. This is what my professor assigned:
The final character of a ten digit International Standard Book Number is a check digit computed so that multiplying each digit by its position in the number (counting from the right) and taking the sum of these products modulo 11 is 0. The furthest digit to the right (which is multiplied by 1) is the check digit, chosen to make the sum correct. It may need to have the value 10, which is represented as the letter X. For example, take the ISBN 0-201-53082-1. The sum of products is 0×10 + 2×9 + 0×8 + 1×7 + 5×6 + 3×5 + 0×4 + 8×3 + 2×2 + 1×1 = 99 0 modulo 11. So the ISBN is valid.
While this may seem more complicated than the first scheme, it can be validated very simply by adding all the products together then dividing by 11. The sum can be computed without any multiplications by initializing two variables, t and sum, to 0 and repeatedly performing t = t + digit; sum = sum + t; (which can be expressed in C as sum += t += digit;). If the final sum is a multiple of 11, then the ISBN is valid.
Ten-digit ISBN Numbers. ISBN numbers prior to 2007 use ten digits. Suppose, for example, an user enters the numbers 0-7637-2478-5. How can a computer application ensure that this is a valid ISBN number? The first step is to strip the “number” of all extraneous dashes, blanks, and similar characters. (Hint: Parse the original string by element, and then assemble a new string that contains ONLY numeric values using StringBuilder). For this example, the resulting number is 0763724785.
The second step is to ensure that the number contains exactly 10 digits.
The third step is to multiply each successive digit in the number by the weights of (“10”, “9”, “8” and so forth to…….”1”) and add the cross products terms.(Note: an ” X” in an ISBN number stands for “10” Hint: loop dude loop and remember strings are indexed in C# making it easier than Java! For this example the sum is 242 and 242 mod 11 =0 and hence it is valid
The final step is to examine the sum and verify that this number is evenly divisible by 11. If so, the ISBN is presumed to be valid. If not, the ISBN presumed invalid.
Build a C# class that will accept an input string and return the result. BE CAREFUL to make sure if the ISBN has an X in the stream then that stands for the number 10.
TEST VALUES: 0-13-152523-9
0-13-148660-8
Write a program to do this with a class and driver class or just code a driver class. What matters is the logic of the program. Assume the string has been inputted. You may use the IsDigit method from Char Class.
The final character of a ten digit International Standard Book Number is a check digit computed so that multiplying each digit by its position in the number (counting from the right) and taking the sum of these products modulo 11 is 0. The furthest digit to the right (which is multiplied by 1) is the check digit, chosen to make the sum correct. It may need to have the value 10, which is represented as the letter X. For example, take the ISBN 0-201-53082-1. The sum of products is 0×10 + 2×9 + 0×8 + 1×7 + 5×6 + 3×5 + 0×4 + 8×3 + 2×2 + 1×1 = 99 0 modulo 11. So the ISBN is valid.
While this may seem more complicated than the first scheme, it can be validated very simply by adding all the products together then dividing by 11. The sum can be computed without any multiplications by initializing two variables, t and sum, to 0 and repeatedly performing t = t + digit; sum = sum + t; (which can be expressed in C as sum += t += digit;). If the final sum is a multiple of 11, then the ISBN is valid.
Ten-digit ISBN Numbers. ISBN numbers prior to 2007 use ten digits. Suppose, for example, an user enters the numbers 0-7637-2478-5. How can a computer application ensure that this is a valid ISBN number? The first step is to strip the “number” of all extraneous dashes, blanks, and similar characters. (Hint: Parse the original string by element, and then assemble a new string that contains ONLY numeric values using StringBuilder). For this example, the resulting number is 0763724785.
The second step is to ensure that the number contains exactly 10 digits.
The third step is to multiply each successive digit in the number by the weights of (“10”, “9”, “8” and so forth to…….”1”) and add the cross products terms.(Note: an ” X” in an ISBN number stands for “10” Hint: loop dude loop and remember strings are indexed in C# making it easier than Java! For this example the sum is 242 and 242 mod 11 =0 and hence it is valid
The final step is to examine the sum and verify that this number is evenly divisible by 11. If so, the ISBN is presumed to be valid. If not, the ISBN presumed invalid.
Build a C# class that will accept an input string and return the result. BE CAREFUL to make sure if the ISBN has an X in the stream then that stands for the number 10.
TEST VALUES: 0-13-152523-9
0-13-148660-8
Write a program to do this with a class and driver class or just code a driver class. What matters is the logic of the program. Assume the string has been inputted. You may use the IsDigit method from Char Class.
His first sentence just goes to show you how lazy people can be. So far the bid is for $50.

New Topic/Question
Reply


MultiQuote














|