Navbar

Tuesday, 27 April 2021

ISC COMPUTER PRACTICAL - 2021 - QUESTION 3 (Matrix Program)


ISC 2021 Computer Practical Question 3 –  Matrix Program


-WRITTEN BY CODERGURUJI

 

  

Solution :


import java.util.*;
class Q3
{
public static void main(String args[])
{  int p=0,s=0,s1=0;
Scanner sc=new Scanner(System.in);
System.out.println("enter m*n");
int m=sc.nextInt();
int n=sc.nextInt();
int a[][]=new int[m][n];
int b[]=new int[1000];
int c[][]=new int[m][n];
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
a[i][j]=sc.nextInt();
}
}
System.out.println("ORIGINAL MATRIX");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
if((i==0)||(i==m-1)||(j==0)||(j==n-1))
   {
     s=s+a[i][j];
 }
System.out.print(a[i][j]+" ");
}
System.out.println();
}
System.out.println("SUM OF THE BOUNDARY ELEMENTS(UNSORTED)= "+s);
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
b[p]=a[i][j];
p++;
}
}
for(int i=0;i<p;i++)
{
for(int j=0;j<p-i-1;j++)
{
if(b[j]<b[j+1])
{
int temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
}
}
p=0;
System.out.println("SORTED MATRIX");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
c[i][j]=b[p];
System.out.print(b[p]+" ");
p++;
if((i==0)||(i==m-1)||(j==0)||(j==n-1))
   {
     s1=s1+c[i][j];
   }
}
System.out.println();
}
System.out.println("SUM OF THE BOUNDARY ELEMENTS(SORTED)= "+s1);
}
}

----------------------------------------end---------------------------------------



ISC COMPUTER PRACTICAL - 2021 - QUESTION 2 (String Program)

 

ISC 2021 Computer Practical Question 2 –  String Program.


-WRITTEN BY CODERGURUJI


      

     

   Solution :



import java.util.*;
class Q2
{
public static void main(String args[])
{  String x="";
int h=0,z=0;
Scanner sc= new Scanner(System.in);
System.out.println("Enter para");
String n=sc.nextLine();
String a[]=new String[1000];
int l=n.length();
for(int i=0;i<l;i++)
{
char ch=n.charAt(i);
if(ch=='.'||ch=='?'||ch=='!')
{
z++;
}
}
if(z==2)
{
for(int i=0;i<l;i++)
{
char ch=n.charAt(i);
if(ch=='.'||ch=='?'||ch=='!')
{
String p=(n.substring(0,i+1));
String m=(n.substring(i+2,l));
n=p+m;
System.out.println(n.substring(0,i+1));
System.out.println(n.substring(i+1));
break;
}
}
for(int i=0;i<l-1;i++)
{
char ch=n.charAt(i);
if(ch!='.'&&ch!='?'&&ch!='!'&&ch!=' ')
{
x=x+ch;
}
else
{
a[h]=x;
h++;
x="";
}
}
System.out.println("COMMON WORDS  FREQUENCY");
for(int i=0;i<h;i++)
{
int c=1;
for(int j=i+1;j<h;j++)
{
if(a[i].equals(a[j]))
{
for(int k=j;k<h-1;k++)
a[k]=a[k+1];
h--;
c++;
}
}
if(c>1)
System.out.println(a[i]+"\t\t"+c);
}
}
else
{
System.out.print("INVALID INPUT");
}
}
}

----------------------------end--------------------------------------------------



Wednesday, 21 April 2021

ISC COMPUTER PRACTICAL - 2021 - QUESTION 1 (Fascinating Number Program)

ISC 2021 Computer Practical Question 1 – Fascinating Number Program


-WRITTEN BY CODERGURUJI


     Solution :


import java.util.*;
class Fascinating
{
public static void main(String agrs[])
{
int f=0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the value for m and n: ");
int m=sc.nextInt();
int n= sc.nextInt();
if(m>n||m<99||n<99||m>10000||n>10000)
{
System.out.println("INVALID INPUT");
}
else
{
System.out.print("THE FASCINATING NUMBERS ARE:");

   for(int i=m;i<=n;i++)
   {
   int n2 = i*2;
   int n3 = i*3;
   String s = "" + i + n2 + n3;
   int l = s.length();
   char ch,ch1;
   int j,c=0;
   
   for(ch1='1';ch1<='9';ch1++)
        {
            c=0;
            for(j=0;j<l;j++)
            {
                ch = s.charAt(j);
                if(ch == ch1)
                    c++;
            }
            if(c!=1)
                break;
        }
        
        if(ch1 > '9')
        {
           f++;
           System.out.print(i+" ");
        }      
}
if(f>0) 
{
System.out.println();
System.out.print("FREQUENCY OF FASCINATING NUMBERS IS:"+f);
}

if(f==0)
{
System.out.print("NIL");
System.out.println();
System.out.print("FREQUENCY OF FASCINATING NUMBERS IS:"+f);
}
}
}
}

----------------------------end----------------------------