Professional Documents
Culture Documents
2013isc Comp Prac
2013isc Comp Prac
aashray | Logout
Home
Resources
Class X
Class XII
Videos
Gallery
Forum
Fun
Friends (0)
Friend Requests
You have no new friend request.
Tutorials
Programming In Java
English
Computer Practical
Viva-Voce
Quick Links
For-loop
While-loop
Do-while loop
Arrays 1D
Arrays 2D
Strings
Functions
Function overloading
Recursive Functions
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. 02011003311 = 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 divisible by 11, hence it is a valid ISBN.
Design a program to accept a ten digit code from the user. For an invalid inout,
display an
appropriate message. Verify the code for its validity in the format specified
below:
Test your program with 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 1
INPUT CODE : 0231428031
OUTPUT : SUM = 122
LEAVES REMAINDER - INVALID ISBN CODE
View/Hide Solution
import java.io.*;
class ISCPrac2013Q1{
int l = isbn.length();
int i, t, ctr, s;
char ch;
if(l!= 10){
System.out.println("INVALID INPUT");
}else{
//PROCEED WITH COMPUTATION ONLY IF ISBN CODE CONTAINS 10 DIGITS
ctr = 10;
s = 0;
ch = isbn.charAt(i);
t = 10;
else
t = ch - 48; //NUMERIC VALUE OF THE ASCII CODE OF DIGIT
ctr--;
}//END OF FOR LOOP
}//END OF MAIN
}//END OF CLASS
// EXAMPLE 1
// INPUT CODE:
// 0201103311
// SUM = 55
// LEAVES NO REMAINDER - VALID ISBN CODE
//EXAMPLE 2
// INPUT CODE:
// 0231428031
// SUM = 122
// LEAVES REMAINDER - INVALID ISBN CODE
//
INPUT
M = 3
4.
5.
16
12
6.
14
7.
8.
OUTPUT
9.
10.
ORIGINAL MATRIX
11.
12.
16
12
13.
14
14.
15.
16.
17.
18.
12
16
19.
14
20.
Example 2
INPUT
M = 22
OUTPUT
View/Hide Solution
import java.util.*;
class ISCPrac2013Q2{
public static void main(String[]args)throws InputMismatchException
{
int M, i, j, k, t;
if(M<=2 || M>=20){
System.out.println("\nSIZE OUT OF RANGE");
}else{
//USE TWO COUNTERS FOR ACCESSING COLUMNS // ONE INCREMENTAL, ONE DECREMENTAL
t = A[i][j];
A[i][j] = A[i][k];
A[i][k] = t;
}
}
}//END OF ELSE
}//END OF MAIN
}//END OF CLASS
//EXAMPLE
// Enter no of rows for a square matrix:
// 3
// Enter 9 elements:
// 4
// 16
// 12
// 8
// 2
// 14
// 6
// 1
// 3
// ORIGINAL MATRIX
// 4 16 12
// 8 2 14
// 6 1 3
// ORIGINAL MATRIX
// 12 16 4
// 14 2 8
// 3 1 6
21. 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 taks:
(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
22.
INPUT
23.
OUTPUT
24.
Example 2
INPUT
OUTPUT
View/Hide Solution
import java.io.*;
class ISCPrac2013Q3{
//EXAMPLE 1
Recently Registered
Guess Questions
Ask a Question
View All Questions
Do you know?
A duck's quack doesn't echo, and no one knows why.
Quote Of The Day
Age is a recommendation in four things- old wood to burn, old wine to drink, old friends to trust, and
old books to read. - Alonzo of Aragon
View all quotes
2014 Mentors. All Rights Reserved. Privacy Policy and Terms of Use
Mon Sep 01 2014 18:13:35 GMT+0530 (India Standard Time)