ISC 2021 Computer Practical Question 2 – String Program.

ISC COMPUTER SCIENCE PRACTICAL SOLVED QUESTIONS ISC COMPUTER PRACTICAL

 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{

char ch=n.charAt(i);

if(ch==’.’||ch==’?’||ch==’!’)

{

ecolebooks.com

z++;

}

}

if(z==2)

{

for(int i=0;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{

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{

int c=1;

for(int j=i+1;j{

if(a[i].equals(a[j]))

{

for(int k=j;ka[k]=a[k+1];

h–;

c++;

}

}

if(c>1)

System.out.println(a[i]+”\t\t”+c);

}

}

else

{

System.out.print(“INVALID INPUT”);

}

}

}

—————————-end————————————————–




');}
Bc0138c3d2dab0944d91d638547c2715

subscriber

Leave a Reply

Your email address will not be published. Required fields are marked *

Accept Our Privacy Terms.*