import java.io.*;
import java.lang.*;
class Stringmani
{
public static void main(String args[]) throws Exception
{int j;
DataInputStream get=new DataInputStream(System.in);
System.out.println("1.Uppercase\n2.Lowercase\n3.concatenation");
System.out.println("4.palindrome\n5.substring search\n");
do
{
System.out.print("Enter your choice: ");
int ch=Integer.parseInt(get.readLine());
switch(ch)
{
case 1:System.out.print("Enter a string : ");
String s1=get.readLine();
System.out.println("Upper case is :"+s1.toUpperCase());
break;
case 2:System.out.print("Enter a string : ");
String s2=get.readLine();
System.out.println("Lowercase is :"+s2.toLowerCase());
break;
case 3:System.out.print("Enter 1st string : ");
String s=get.readLine();
System.out.print("Enter 2nd string : ");
String p=get.readLine();
String s3=s+p;
System.out.println("concated string : "+s3);
break;
case 4: System.out.print("Enter a string : ");
String a=get.readLine();
StringBuffer b=new StringBuffer(a);
b.reverse();
String c=b.toString();
if(a.equals(c))
System.out.println("String is palindrome ");
else
System.out.println("String is not palindrome ");
break;
case 5:try
{
int r=0;
System.out.print("Enter a string : ");
String ss1=get.readLine();
System.out.print("Enter the word to find : ");
String ss2=get.readLine();
int k=ss2.length();
int t=ss1.length();
for(int i=0;i<t;i++)
{
String ss3=ss1.substring(i,i+k);
if(ss3.equals(ss2))
{
r=1;
System.out.println("the substring is found");
break;
}
}
if(r==0)
System.out.println("the substring is not found");
}
catch(StringIndexOutOfBoundsException e)
{
}
break;
default:System.out.print("Wrong choice...");
}
System.out.print("To continue press 1:");
j=Integer.parseInt(get.readLine());
}while(j==1);
}
}
import java.lang.*;
class Stringmani
{
public static void main(String args[]) throws Exception
{int j;
DataInputStream get=new DataInputStream(System.in);
System.out.println("1.Uppercase\n2.Lowercase\n3.concatenation");
System.out.println("4.palindrome\n5.substring search\n");
do
{
System.out.print("Enter your choice: ");
int ch=Integer.parseInt(get.readLine());
switch(ch)
{
case 1:System.out.print("Enter a string : ");
String s1=get.readLine();
System.out.println("Upper case is :"+s1.toUpperCase());
break;
case 2:System.out.print("Enter a string : ");
String s2=get.readLine();
System.out.println("Lowercase is :"+s2.toLowerCase());
break;
case 3:System.out.print("Enter 1st string : ");
String s=get.readLine();
System.out.print("Enter 2nd string : ");
String p=get.readLine();
String s3=s+p;
System.out.println("concated string : "+s3);
break;
case 4: System.out.print("Enter a string : ");
String a=get.readLine();
StringBuffer b=new StringBuffer(a);
b.reverse();
String c=b.toString();
if(a.equals(c))
System.out.println("String is palindrome ");
else
System.out.println("String is not palindrome ");
break;
case 5:try
{
int r=0;
System.out.print("Enter a string : ");
String ss1=get.readLine();
System.out.print("Enter the word to find : ");
String ss2=get.readLine();
int k=ss2.length();
int t=ss1.length();
for(int i=0;i<t;i++)
{
String ss3=ss1.substring(i,i+k);
if(ss3.equals(ss2))
{
r=1;
System.out.println("the substring is found");
break;
}
}
if(r==0)
System.out.println("the substring is not found");
}
catch(StringIndexOutOfBoundsException e)
{
}
break;
default:System.out.print("Wrong choice...");
}
System.out.print("To continue press 1:");
j=Integer.parseInt(get.readLine());
}while(j==1);
}
}






0 comments:
Post a Comment