ISC Computer 2014 Practical Paper Solved
Question :1
Inputs two integers M and N and
display the composit prime number present between M and N. Also displays its
frequency.
Sample
Input : 
M
= 1100
N
= 1200
Sample
Output :
THE
COMPOSIT MAGIC INTEGERS ARE :
1108
1126 1135 1144 1162 1180 1189 1198 
FREQUENCY
OF COMPOSIT MAGIC INTEGERS : 8
//Publisher
: Sharma Tutorials Jamshedpur
//Author
: Shubham Kumar Sharma
//Uploaded
At : sharmatutorialsjsr.blogspot.com
import
java.util.*;
public
class Composit_Magic
{
intisComposit(int
a)
    {
inti,f=0,r=0;
        for(i=1;i<=a;i++)
        {
            if(a%i==0)
            f++;
        }
        if(f>2)
        r=1;
        return r;
    }
intisMagic(int
b)
    {
intt,r=0,s=0,l;
        t=b;
for(;t!=0;)
        {
            l=t%10;
            s=s+l;
            t=t/10;
            if((s>9)&&(t==0))
            {
                t=s;
                s=0;
            }
        }
        if(s==1)
        r=1;
        return r;
    }
    public static void main()
    {
        Scanner in=new Scanner(System.in);
Composit_Magicob=new
Composit_Magic();
intm,n,i,f=0;
System.out.println("Enter
Starting Range : ");
        m=in.nextInt();
System.out.println("Enter
Ending Range : ");
        n=in.nextInt();
        if(m<n)
        {
System.out.println("THE
COMPOSIT MAGIC INTEGERS ARE : ");
            for(i=m;i<=n;i++)
            {
               
if((ob.isComposit(i)==1)&&(ob.isMagic(i)==1))
                {
System.out.print(i+"
");
                    f++;
                }
            }
System.out.println();
System.out.println("FREQUENCY
OF COMPOSIT MAGIC INTEGERS : "+f);
        }
        else
System.out.println("INVALID
INPUT");
    }
}
Question : 2
Inputs
a matrix of order M 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
 
 
 
 
 M and displays original matrix, checks whether
the matrix is symmetric or not and also displays the sum of both the diagonals.
Sample
Input :
1      2      3      
2      4      5      
3      5      6      
Sample
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
//Publisher
: Sharma Tutorials Jamshedpur
//Author
: Shubham Kumar Sharma
//Uploaded
At : sharmatutorialsjsr.blogspot.com
import
java.util.*;
public
class Symmetric
{
    public static void main()
    {
        Scanner in=new Scanner(System.in);
intm,i,j,flag=0,ld=0,rd=0;
System.out.println("Enter
size of matrix : ");
        m=in.nextInt();
        if((m>2)&&(m<10))
        {
inta[][]=new
int[m][m];
System.out.println("Enter
Elements in the matrix : ");
            for(i=0;i<m;i++)
            {
                for(j=0;j<m;j++)
                {
                    a[i][j]=in.nextInt();
                }
            }
System.out.println("ORIGINAL
MATRIX");
            for(i=0;i<m;i++)
            {
                for(j=0;j<m;j++)
                {
System.out.print(a[i][j]+"\t");
                }
System.out.println();
            }
            for(i=0;i<m;i++)
            {
                for(j=0;j<m;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<m;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");
    }
}
Question : 3
Inputs
a sentence in upper case and remove all the extra space present in a sentence.
Also inputs a word with its position in a sentence and display the new string.
Sample
Input :
SHUBHAM
HIS PUBLISHES HIS PROGRAMS AT SHARMA TUTORIALS JAMSHEDPUR.
Enter
a word to be deleted :
HIS
Enter
a position of word in a sentence :
2
Sample
Output :
SHUBHAM
PUBLISHES HIS PROGRAMS AT SHARMA TUTORIALS JAMSHEDPUR
//Publisher
: Sharma Tutorials Jamshedpur
//Author
: Shubham Kumar Sharma
//Uploaded
At : sharmatutorialsjsr.blogspot.com
import
java.util.*;
public
class Sentence
{
    public static void main()
    {
        Scanner in=new Scanner(System.in);
        String s,w[],wrd,str="";
inti,p=0;
System.out.println("ENTER
YOUR SENTENCE : ");
        s=in.nextLine();
       
if((s.charAt(s.length()-1)=='?')||(s.charAt(s.length()-1)=='.')||(s.charAt(s.length()-1)=='!'))
        {
            w=s.split("[.?! ]+");
            for(i=0;i<w.length;i++)
           
{
                if(w[i].equals(""))
                {
str=str;
                }
                else
                {
str=str+w[i]+"
";
                }
            }
str=str.trim();
System.out.println("Enter
a word to be deleted : ");
wrd=in.nextLine();
System.out.println("Enter
a position of word \""+wrd+"\" in a sentence : ");
            p=in.nextInt();
            w=str.split(" ");
str="";
            if((p-1)<w.length)
            {
               
if(w[p-1].equalsIgnoreCase(wrd))
                {
                    for(i=0;i<w.length;i++)
                    {
                        if(i==(p-1))
i++;
str=str+w[i]+"
";
                    }
                }
str=str.trim();
System.out.println("New
Sentence : "+str);
            }
        }
        else
System.out.println("Invalid
Input");
    }
}
very useful site!!
ReplyDelete