Share this:
ISC COMPUTER PRACTICAL PAPER 2014 SOLVED
ISC COMPUTER PRACTICAL 2014 SOLVED
Question 1:
A Composite Magic number is a positive integer which is composite as well as a magic number.
Composite number:
A composite number is a number that has more than two factors.
For example: 10
Factors are: 1, 2, 5, 10
Magic number:
A magic number is a number in which the eventual sum of the digits is equal to 1
For example: 28=2+8=10=1+0=1
Accept two positive integers m and n, where m is less than n as user input. Display the number of Composite magic integers that are in the range between m and n (both inclusive) and output them along with the frequency, in the format specified below.
Test your program with the sample data and some random data:
Example 1:
INPUT:
m = 10
n = 100
OUTPUT:
THE COMPOSITE MAGIC INTEGERS ARE:
10, 28, 46, 55, 64, 82, 91, 100
FREQUENCY OF COMPOSITE MAGIC INTEGERS IS: 8
Example 2:
INPUT:
m = 1200
n = 1300
OUTPUT:
THE COMPOSITE MAGIC INTEGERS ARE:
1207, 1216, 1225, 1234, 1243, 1252, 1261, 1270, 1288
FREQUENCY OF COMPOSITE MAGIC INTEGERS IS: 9
Example 3:
INPUT:
m = 120
n = 99
OUTPUT:
INVALID INPUT
Solution:
import java.util.*;
class MagicComposite
{
boolean isComposite(int n)
{
int count=0;
for(int i=1;i<=n;i++) {
if(n%i==0) count++;
}
if(count>2)
return true;
else
return false;
}
int sumDig(int n)
{
int s = 0;
while(n>0)
{
s = s + n%10;
n = n/10;
}
return s;
}
boolean isMagic(int n)
{
int a = sumDig(n);
while(a>9)
{
a = sumDig(a);
}
if(a == 1)
return true;
else
return false;
}
public static void main(String args[])
{
MagicComposite ob = new MagicComposite();
Scanner sc=new Scanner(System.in);
System.out.print(“Enter the lower limit(m) : “);
int m=sc.nextInt();
System.out.print(“Enter the upper limit(n) : “);
int n=Sc.nextInt();
int c=0;
}
}
Output:
Enter the lower limit(m) : 1200
Enter the upper limit(n) : 1300
The Composite Magic Integers are:
1207, 1216, 1225, 1234, 1243, 1252, 1261, 1270, 1288
The frequency of Composite Magic Integers is : 9
——————–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 10. Accept the value of M as user input. Display an appropriate message for an invalid input. Allow the user to input integers into this matrix. Perform the following tasks:
(a) Display the original matrix.
(b) Check if the given matrix is Symmetric or not.
A square matrix is said to be Symmetric, if the element of the (i)th row and (j)th column is equal to the element of the (i)th row and (j)th column.
(c) Find the sum of the elements of left diagonal and the sum of the elements of right diagonal of the matrix and display them.
Test your program with the sample data and some random data:
Example 1
INPUT : M = 3
1 2 3
2 4 5
3 5 6
OUTPUT :
ORIGINAL MATRIX
1 2 3
2 4 5
3 5 6
THE GIVEN MATRIX IS SYMMETRIC
The sum of the left diagonal = 11
The sum of the right diagonal = 10
Example 2
INPUT : M = 4
7 8 9 2
4 5 6 3
8 5 3 1
7 6 4 2
OUTPUT :
ORIGINAL MATRIX
7 8 9 2
4 5 6 3
8 5 3 1
7 6 4 2
THE GIVEN MATRIX IS NOT SYMMETRIC
The sum of the left diagonal = 17
The sum of the right diagonal = 20
Example 3
INPUT : M = 22
OUTPUT : THE MATRIX SIZE IS OUT OF RANGE
Solution:
import java.util.*;
public class Symmetric
{
public static void main()
{
Scanner in=new Scanner(System.in);
int m,i,j,flag=0,ld=0,rd=0;
System.out.println(“Enter size of matrix : “);
m=in.nextInt();
if((m>2)&&(m<10)) {
int a[][]=new int[m][m];
System.out.println(“Enter Elements in the matrix : “);
for(i=0;i
for(j=0;j
a[i][j]=in.nextInt();
}
}
System.out.println(“ORIGINAL MATRIX”);
for(i=0;i
for(j=0;j
System.out.print(a[i][j]+”\t”);
}
System.out.println();
}
for(i=0;i
for(j=0;j
if(a[i][j]!=a[j][i])
{
flag=1;
break;
}
}
}
if(flag==0)
System.out.println(“THE GIVEN MATRIX IS SYMMETRIC”);
else
System.out.println(“THE GIVEN MATRIX IS NOT SYMMETRIC”);
for(i=0;i
ld=ld+a[i][i];
rd=rd+a[i][m-1-i];
}
System.out.println(“The sum of the left diagonal : “+ld);
System.out.println(“The sum of the right diagonal : “+rd);
}
else
System.out.println(“THE MATRIX SIZE IS OUT OF RANGE”);
}
}
————————–end————————–
Question 3:
Write a program to accept a sentence which may be terminated by either ‘.’ ‘?’ or ‘!’ only. Any other character may be ignored. The words may be separated by more than one blank space and are in UPPER CASE.
Perform the following tasks:
(a) Accept the sentence and reduce all the extra blank space between two words to
a single blank space.
(b) Accept a word from the user which is part of the sentence along with its
position number and delete the word and display the sentence.
Test your program with the sample data and some random data:
Example 1
INPUT: A MORNING WALK IS A IS BLESSING FOR THE WHOLE DAY.
WORD TO BE DELETED: IS
WORD POSITION IN THE SENTENCE: 6
OUTPUT: A MORNING WALK IS A BLESSING FOR THE WHOLE DAY.
Example 2
INPUT: AS YOU SOW, SO SO YOU REAP.
WORD TO BE DELETED: SO
WORD POSITION IN THE SENTENCE: 4
OUTPUT: AS YOU SOW, SO YOU REAP.
Example 3
INPUT: STUDY WELL ##.
OUTPUT: INVALID INPUT.
Solution:
import java.util.*;
class RemoveWord
{
public static void main (String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print(“Enter a sentence : “);
String s = sc.nextLine();
s = s.toUpperCase();
int l = s.length();
char last = s.charAt(l-1);
if(last != ‘.’ && last != ‘?’ && last != ‘!’)
{
System.out.println(“Invalid Input. End a sentence with either ‘.’, ‘?’ or ‘!’ only”);
}
else
{
StringTokenizer str = new StringTokenizer(s,” .?!”);
int c = str.countTokens();
String w=””,ans = “”;
System.out.print(“Enter the word to delete : “);
String del = sc.next();
System.out.print(“Enter the word position is the sentence : “);
int x = sc.nextInt();
if(x<1 || x>c)
{
System.out.println(“Sorry! The word position entered is out of range”);
}
else
{
for(int i=1; i<=c; i++) {
w = str.nextToken();
if(w.equals(del)==true && i == x)
continue;
ans = ans + w + ” “;
}
System.out.print(“Output : “+ans.trim()+last);
}
}
}
}
——————–end——————————-
Output:
1. Enter any sentence : A MORNING WALK IS A IS BLESSING FOR THE WHOLE DAY.
Enter the word to delete : IS
Enter the word position is the sentence : 6
Output : A MORNING WALK IS A BLESSING FOR THE WHOLE DAY.
2. Enter any sentence : STUDY WELL ##
OUTPUT : Invalid Input. End a sentence with either ‘.’, ‘?’ or ‘!’