Saturday , 20 July 2019
Latest Posts
Home » Class 12 » ISC 2013 [Question 1] Practical Paper Solved (ISBN Number)

# ISC 2013 [Question 1] Practical Paper Solved (ISBN Number)

#### Question:

An ISBN (International Standard Book Number) is a ten digit code which uniquely identifies a book.

The first nine digits represent the Group, Publisher and Title of the book and the last digit is used to check whether ISBN is correct or not.

Each of the first nine digits of the code can take a value between 0 and 9. Sometimes it is necessary to make the last digit equal to ten; this is done by writing the last digit of the code as X.

To verify an ISBN, calculate 10 times the first digit, plus 9 times the second digit, plus 8 times the third and so on until we add 1 time the last digit. If the final number leaves no remainder when divided by 11, the code is a valid ISBN.

For Example:

1. 0201103311 = 10*0 + 9*2 + 8*0 + 7*1 + 6*1 + 5*0 + 4*3 + 3*3 + 2*1 + 1*1 = 55

Since 55 leaves no remainder when divided by 11, hence it is a valid ISBN.

2. 007462542X = 10*0 + 9*0 + 8*7 + 7*4 + 6*6 + 5*2 + 4*5 + 3*4 + 2*2 + 1*10 = 176

Since 176 leaves no remainder when divided by 11, hence it is a valid ISBN.

3. 0112112425 = 10*0 + 9*1 + 8*1 + 7*2 + 6*1 + 5*1 + 4*1 + 3*4 + 2*2 + 1*5 = 71

Since 71 leaves no remainder when divided by 11, hence it is not a valid ISBN.

Design a program to accept a ten digit code from the user. For an invalid input, display an appropriate message. Verify the code for its validity in the format specified below:

Test your program with the sample data and some random data:

Example 1

INPUT CODE: 0201530821

OUTPUT : SUM = 99
LEAVES NO REMAINDER – VALID ISBN CODE

Example 2

INPUT CODE: 035680324

OUTPUT : INVALID INPUT

Example 3

INPUT CODE: 0231428031

OUTPUT : SUM = 122
LEAVES REMAINDER – INVALID ISBN CODE

#### Programming Code:

```/**
* The class ISBN_ISC2013 inputs a 10 digit code and checks whether it is a valid ISBN code or not
* @author : www.javaforschool.com
* @Program Type : BlueJ Program - Java
* @Question Year : ISC Practical 2013 Question 1
*/
import java.io.*;
class ISBN_ISC2013
{
public static void main()throws IOException
{
System.out.print("Enter a 10 digit code : ");
int l=s.length();
if(l!=10)
System.out.println("Output : Invalid Input");
else
{
String ch;
int a=0, sum=0, k=10;
for(int i=0; i<l; i++)
{
ch=Character.toString(s.charAt(i));
if(ch.equalsIgnoreCase("X"))
a=10;
else
a=Integer.parseInt(ch);
sum=sum+a*k;
k--;
}
System.out.println("Output : Sum = "+sum);
if(sum%11==0)
System.out.println("Leaves No Remainder - Valid ISBN Code");
else
System.out.println("Leaves Remainder - Invalid ISBN Code");
}
}
}
```

#### Output:

1. Enter a 10 digit code : 0201530821
Output : Sum = 99
Leaves No Remainder – Valid ISBN Code

2. Enter a 10 digit code : 035680324
Output : Invalid Input

## Infix Postfix Prefix Conversion – Correct Method (ISC Computer Science)

In this video we discuss about the correct way of converting an Infix Expression to Postfix and Prefix.

1. Can i know why 48 is deducted from ch to get dig in else part??

• Hello Ankita,
In the above program we are extracting digits in the form of characters using charAt() function.
Since the digits are being extracted in the form of characters, we cannot perform the desired mathematical operation on them.
Hence, we need to convert these digits from character form to its equivalent Integer form.
To do this we make use of the ASCII code. In ASCII, the characetrs from ‘0’ to ‘9’ have an ASCII value of 48 to 57.
Hence we need to subtract 48 from any digit in character form to get that same digit in integer form.
Example: If you want to convert a character ‘5’ into an integer 5, then we will have to perform the below given operation:
‘5’ – 48
= ASCII value of ‘5’ – 48
= 53 – 48
= 5

This is the reason we are subtracting 48 from ch to get dig.

I hope the doubt is cleared.

Regards,
guideforschool

2. Can get why there is X

• There is ‘X’ because it says in the question “Sometimes it is necessary to make the last digit equal to ten; this is done by writing the last digit of the code as X.”

3. Are comments absolutely compulsory in ICSE programs?
Do they count marks?

• Yes, they carry marks (very minimum, probably 1 or 2). It is enough to give comments in just 5-6 lines. But if you haven’t given them, then don’t worry. Sometimes, examiners overlook them 🙂 … Relax !

4. Can i store the ISBN code in an integer variable and extract the digits individually in a loop and find the sum?

• Since according to the question, an ISBN number can contain the letter ‘X’ also, hence, it cannot be stored in an integer. If you store it in an integer, then, it will only work for ISBN numbers which do not contain’X’.

• well nothing was mentioned in the question……………….
But will i be getting marks for it??

• Yes, the same question came in ICSE 2013 without the ‘X’ part. Hence, you can save it in an integer variable and will get full marks if you wrote everything else correct.

• Thank you very much……………indeed i have taken an int and have probably written every thing correct!

5. where is the working