Sunday, 20 November 2016

ISC Computer 2016 Practical Paper Solved



ISC Computer 2016 Practical Paper Solved


Question :1
Inputs a number and check whether a number is circular prime or not.
Sample Input :
131 
Sample Output :
131
311
113
131 IS A CIRCULAR PRIME
//Publisher : Sharma Tutorials Jamshedpur
//Author : Shubham Kumar Sharma
import java.util.*;
public class Circular_Prime
{
    public static void main()
    {
        Scanner in=new Scanner(System.in);
intn,d,i,r,c,j,f=0,pr=0,t;
System.out.print("Enter your number : ");
        n=in.nextInt();
        t=n;
        d=Integer.toString(n).length();
        for(i=0;i<d;i++)
        {
System.out.println(n);
            r=n%(int)(Math.pow(10,d-1));
            c=r*10+n/(int)(Math.pow(10,d-1));
            for(j=1;j<=c;j++)
            {
                if(c%j==0)
                f++;
            }
            if(f==2)
            {
pr++;
                f=0;
            }
            n=c;
        }
        if(pr==d)
System.out.println(t+" IS A CIRCULAR PRIME");
        else
System.out.println(t+" IS NOT A CIRCULAR PRIME");
    }
}


Question : 2
Inputs a matrix of order M  M and displays original matrix, arranged matrix in ascending order, elements of both the diagonal and sum of its diagonals.
Sample Input :
1      2      3      4      5     
6      9      8      7      7     
8      9      6      5      4     
3      2      15    6      4     
9      3      8      9      2     
Sample Output :
ORIGINAL MATRIX
1      2      3      4      5     
6      9      8      7      7     
8      9      6      5      4     
3      2      15    6      4     
9      3      8      9      2     
REARRANGED MATRIX
1      2      3      4      5     
6      2      5      6      7     
8      6      7      8      4     
3      9      9      15    4     
9      3      8      9      2     
DIAGONAL ELEMENTS
1                              5     
        2              6             
                7                     
        9              15           
9                              2     
SUM OF THE DIAGONAL ELEMENTS : 56

//Publisher : Sharma Tutorials Jamshedpur
//Author : Shubham Kumar Sharma
import java.util.*;
public class Matrix_2
{
    public static void main()
    {
        Scanner in=new Scanner(System.in);
intm,i,j,k,l,t,s=0;
System.out.println("Enter size of matrix : ");
        m=in.nextInt();
        if((m>3)&&(m<10))
        {
inta[][]=new int[m][m];
intb[][]=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=1;i<m-1;i++)
            {
                for(j=1;j<m-1;j++)
                {
                    for(k=1;k<m-1;k++)
                    {
                        for(l=1;l<m-1;l++)
                        {
                            if(a[i][j]<a[k][l])
                            {
                                t=a[i][j];
                                a[i][j]=a[k][l];
                                a[k][l]=t;
                            }
                        }
                    }
                }
            }
System.out.println("REARRANGED MATRIX");
            for(i=0;i<m;i++)
            {
                for(j=0;j<m;j++)
                {
System.out.print(a[i][j]+"\t");
                }
System.out.println();
            }
System.out.println("DIAGONAL ELEMENTS");
            for(i=0;i<m;i++)
            {
                for(j=0;j<m;j++)
                {
                    if((i==j)||((i+j)==(m-1)))
                    {
System.out.print(a[i][j]+"\t");
                        s=s+a[i][j];
                    }
                    else
System.out.print("\t");
                }
System.out.println();
            }
System.out.println("SUM OF THE DIAGONAL ELEMENTS : "+s);
        }
        else
System.out.println("THE MATRIX SIZE IS OUT OF RANGE");
    }
}


Question : 3
Inputs a sentence in upper case and display the number of words that starts and ends with vowel. Also displays a new sentence containing all the words that starts and ends with vowels followed by rest of the words.
Sample Input :
ANISHA AND ANAMIKA ARE READING THE PROGRAMS AT SHARMA TUTORIALS JAMSHEDPUR.
Sample Output :
NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL : 3
NEW STRING :
ANISHA ANAMIKA ARE AND READING THE PROGRAMS AT SHARMA TUTORIALS JAMSHEDPUR
//Publisher : Sharma Tutorials Jamshedpur
//Author : Shubham Kumar Sharma
import java.util.*;
public class Sentence_2
{
    public static void main()
    {
        Scanner in=new Scanner(System.in);
        String s,w[],v="",nv="",str;
        char f,l;
inti,count=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++)
            {
                f=w[i].charAt(0);
                l=w[i].charAt(w[i].length()-1);
                if(((f=='a')||(f=='e')||(f=='i')||(f=='o')||(f=='u')||(f=='A')||(f=='E')||(f=='I')||(f=='O')||(f=='U'))&&((l=='a')||(l=='e')||(l=='i')||(l=='o')||(l=='u')||(l=='A')||(l=='E')||(l=='I')||(l=='O')||(l=='U')))
                {
                    count++;
                    v=v+w[i]+" ";
                }
                else
                {
nv=nv+w[i]+" ";
                }
            }
str=v.trim()+" "+nv.trim();
str=str.trim();
System.out.println("NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL : "+count);
System.out.println("NEW STRING : \n"+str);
        }
        else
System.out.println("INVALID INPUT");
    }
}

ISC Computer 2015 Practical Paper Solved



ISC Computer 2015 Practical Paper Solved


Question :1
Inputs two integers M and N and display the number greater than M whose digit’s sum is equal to N and number of digits of new number.
Sample Input : 
M = 110
N = 11
Sample Output :
The Required Number is : 119 (1 + 1 + 9 = 11)
Total Number of Digits is : 3
//Publisher : Sharma Tutorials Jamshedpur
//Author : Shubham Kumar Sharma
import java.util.*;
public class Number
{
    public static void main()
    {
        Scanner in=new Scanner(System.in);
intm,n,t,s=0,d=0,r;
System.out.print("Enter the Value of M : ");
        m=in.nextInt();
System.out.print("Enter the Value of N : ");
        n=in.nextInt();
        if((m>=100)&&(m<=10000)&&(n<100))
        {
            while(true)
            {
                t=m;
for(;t!=0;)
                {
                    r=t%10;
                    s=s+r;
                    t=t/10;
                    d++;
                }
                if(s==n)
                {
System.out.println("The Required Number is : "+m);
System.out.println("Total Number of Digits is : "+d);
                    break;
                }
                s=0;
                d=0;
                m++;
            }
        }
        else
        {
System.out.println("INVALID INPUT");
        }
    }
}


Question : 2
Inputs a matrix of order M  M and displays original matrix, rotated matrix and sum of corner elements.
Sample Input :
1      2      3     
2      4      5     
3      5      6     
Sample Output :
ORIGINAL MATRIX
1      2      3     
4      5      6     
7      8      9     
MATRIX AFTER ROTATION
7      4      1     
8      5      2     
9      6      3     
Sum of the corner elements : 20

//Publisher : Sharma Tutorials Jamshedpur
//Author : Shubham Kumar Sharma
import java.util.*;
public class Matrix_1
{
    public static void main()
    {
        Scanner in=new Scanner(System.in);
intm,i,j,s;
System.out.println("Enter size of matrix : ");
        m=in.nextInt();
        if((m>2)&&(m<10))
        {
inta[][]=new int[m][m];
intb[][]=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++)
                {
                    b[j][m-1-i]=a[i][j];
                }
            }
System.out.println("MATRIX AFTER ROTATION");
            for(i=0;i<m;i++)
            {
                for(j=0;j<m;j++)
                {
System.out.print(b[i][j]+"\t");
                }
System.out.println();
            }
            s=a[0][0]+a[0][m-1]+a[m-1][m-1]+a[m-1][0];
System.out.println("Sum of the corner elements : "+s);
        }
        else
System.out.println("SIZE OUT OF RANGE");
    }
}


Question : 3
Inputs a sentence and coverts all the first letter of a word to upper case and display the number of vowels and consonants present in each word of a sentence.
Sample Input :
Shubham kumarsharma solved ISC questions at sharma tutorials jamshedpur.
Sample Output :
New Sentance :
Shubham Kumar Sharma Solved ISC Questions At Sharma Tutorials Jamshedpur.
Words             Vowels    Consonants
Shubham                2              5
Kumar                    2              3
Sharma                   2              4
Solved                     2              4
ISC                          1              2
Questions               4              5
At                            1              1
Sharma                   2              4
Tutorials                 4              5
Jamshedpur           3              7
//Publisher : Sharma Tutorials Jamshedpur
//Author : Shubham Kumar Sharma
import java.util.*;
public class Vowels_Consonants
{
    public static void main()
    {
        Scanner in=new Scanner(System.in);
        String s,w[],u="";
inti,j,v=0,co=0;
        char c;
System.out.println("Enter Your Sentence : ");
        s=in.nextLine();
        if((s.charAt(s.length()-1)=='.')||(s.charAt(s.length()-1)=='?'))
        {
            u=u+Character.toUpperCase(s.charAt(0));
            for(i=1;i<s.length();i++)
            {
                if((s.charAt(i)==' ')&&(Character.isLetter(s.charAt(i+1))))
                u=u+' '+Character.toUpperCase(s.charAt(++i));
                else
                u=u+s.charAt(i);
            }
System.out.println("New Sentance : "+u);
            w=u.split("[.? ]+");
System.out.println("Words\t\tVowels\tConsonants");
            for(i=0;i<w.length;i++)
            {
                for(j=0;j<w[i].length();j++)
                {
                    c=w[i].charAt(j);
                    if((c=='a')||(c=='e')||(c=='i')||(c=='o')||(c=='u')||(c=='A')||(c=='E')||(c=='I')||(c=='O')||(c=='U'))
                    v++;
                    else
                    co++;
                }
System.out.println(w[i]+"\t\t"+v+"\t"+co);
                v=0;
                co=0;
            }
        }
        else
System.out.println("Invalid Input");
    }
}