## ISC COMPUTER PRACTICAL 2013 SOLVED

### Question 1:

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

ecolebooks.com

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

### Solution:

import java.util.*;
class ISBN
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print(“Enter a 10 digit code : “);
String s=sc.nextLine();
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            {
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”);
}
}
}
————————–end—————————

### Question 2:

Write a program to declare a square matrix A[ ] [ ] of order (M x M) where ‘M’ is the number of rows and the number of columns such that M must be greater than 2 and less than 20. Allow  the user to input integers into this matrix. Display appropriate error message for an invalid input. Perform the following tasks:

(a) Display the input matrix.
(b) Create a mirror image matrix.
(c) Display the mirror image matrix.

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

Example 1

INPUT : M = 3
4       16      12
8        2       14
4        1        3

OUTPUT :

ORIGINAL MATRIX

4       16       12
8         2       14
4         1        3

MIRROR IMAGE MATRIX

12      16      4
14       2      8
3         1      4

Example 2

INPUT : M = 22

OUTPUT : SIZE OUT OF RANGE

### Solution :

import java.util.*;
class mirror
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println(“Enter the size of the square matrix :”);
int m=sc.nextInt();
if(m<2||m>20)
{
System.out.println(“SIZE OUT OF RANGE”);
}
else
{
int b[][]=new int[m][m];
int a[][]=new int[m][m];
for(int i=0;i{
for(int j=0;j{
a[i][j]=sc.nextInt();
}
}
for(int i=0;i{ int k=2;
for(int j=0;j{
b[i][j]=a[i][k];
k–;
}
}
System.out.println(“ORIGINAL MATRIX”);
for(int i=0;i{
for(int j=0;j{
System.out.print(a[i][j]+” “);
}
System.out.println();
}
System.out.println(“MIRRIOR IMAGE”);
for(int i=0;i{
for(int j=0;j{
System.out.print(b[i][j]+” “);
}
System.out.println();
}
}
}
}

Output:
Enter the size of the square matrix : 4
Enter the elements of the Matrix:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
*********************
The original matrix:
*********************
1        2      3      4
5        6      7      8
9     10     11     12
13   14     15     16
*********************
The Mirror Image:
*********************
4       3       2      1
8       7       6      5
12   11      10     9
16   15      14    13

—————————–end———————

### Question 3:

A Palindrome is a word that may be read the same way in either direction.

Accept a sentence in UPPER CASE which is terminated by either ” . “, ” ? ” or ” ! “.

Each word of the sentence is separated by a single blank space.

Perform the following tasks:

(a) Display the count of palindromic words in the sentence.
(b) Display the Palindromic words in the sentence.

Example of palindromic words: MADAM, ARORA, NOON

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

Example 1

INPUT : MOM AND DAD ARE COMING AT NOON.

OUTPUT : MOM DAD NOON
NUMBER OF PALINDROMIC WORDS : 3

Example 2

INPUT : NITIN ARORA USES LIRIL SOAP.

OUTPUT : NITIN ARORA LIRIL
NUMBER OF PALINDROMIC WORDS : 3

Example 3

INPUT : HOW ARE YOU?

OUTPUT : NO PALINDROMIC WORDS

### Solution :

import java.util.*;
class Palindrom
{
boolean isPalin(String s)
{
int l=s.length();
String rev=””;
for(int i=l-1; i>=0; i–)
{
rev=rev+s.charAt(i);
}
if(rev.equals(s))
return true;
else
return
false;
}
public static void main(String args[])throws IOException
{
Palindrom ob=new Palindrom();
System.out.print(“Enter any sentence : “);
s=s.toUpperCase();
StringTokenizer str = new StringTokenizer(s,”.?! “);
int w=str.countTokens();
String word[]=new String[w];
}
}
}

Output:
1. Enter any sentence : MOM AND DAD ARE COMING AT NOON.
OUTPUT : MOM DAD NOON
Number of Palindromic Words : 3

2. Enter any sentence : HOW ARE YOU?
OUTPUT : No Palindrome Words
———————end————————-

subscriber

By

By

By

By