Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please use printf and scanf if its required 2. Write a program to test an ISBN number to see if it is valid using the
please use printf and scanf if its required
2. Write a program to test an ISBN number to see if it is valid using the weighted sum method. Weighted sum method: Declare two arrays with ten elements each. Enter the 10 digits of an ISBN number in one array, one digit in each array slot. In the second array enter weighting factors from 10 to 1 as shown in the table below. You may choose to have a third array with weighted values (products of corresponding elements of the other two arrays. The ISBN number is valid ifthe sum of the weighted values modulus 1 l is O. An le is shown in the table below for ISBN number 0078818095 ISBN digit Weighted Value Weight 10 56 56 48 32 18 220 4 Weighted Sum Table 1. Weighted Sum Method for ISBN Validity Test For two extra points test the validity of the ISBN number by the Sum of Sums method. Sum of Sums: In this method the original ISBN array is used again. A second array is created by adding each digit of the ISBN array to the sum of the previous digits. A third array is the sum of the previous sums. The ISBN number is valid if the sum of the sums modulus 11 is 0. An example is shown below ISBN digit Sum of Di Sum of Sums 15 23 24 32 32 41 46 45 69 101 133 174 220 Table2. Sum of Sums Method for ISBN Validity Test Problem adapter from Computer Science A Structured Programming Approach Using C by Forouzan & Glberg 2. Write a program to test an ISBN number to see if it is valid using the weighted sum method. Weighted sum method: Declare two arrays with ten elements each. Enter the 10 digits of an ISBN number in one array, one digit in each array slot. In the second array enter weighting factors from 10 to 1 as shown in the table below. You may choose to have a third array with weighted values (products of corresponding elements of the other two arrays. The ISBN number is valid ifthe sum of the weighted values modulus 1 l is O. An le is shown in the table below for ISBN number 0078818095 ISBN digit Weighted Value Weight 10 56 56 48 32 18 220 4 Weighted Sum Table 1. Weighted Sum Method for ISBN Validity Test For two extra points test the validity of the ISBN number by the Sum of Sums method. Sum of Sums: In this method the original ISBN array is used again. A second array is created by adding each digit of the ISBN array to the sum of the previous digits. A third array is the sum of the previous sums. The ISBN number is valid if the sum of the sums modulus 11 is 0. An example is shown below ISBN digit Sum of Di Sum of Sums 15 23 24 32 32 41 46 45 69 101 133 174 220 Table2. Sum of Sums Method for ISBN Validity Test Problem adapter from Computer Science A Structured Programming Approach Using C by Forouzan & Glberg
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started