StringsQ1 11
StringsQ1 11
import java.io.*;
class SQ1
{
public static void main(String[] args)throws IOException
{
String str;
String rev="";
int l;
l=str.length();
for(int i=l-1; i>=0; i--)
{
rev=rev+str.charAt(i);
}
System.out.println(rev);
if(rev.equals(str))
{
System.out.println("PALLINDROME");
}
else
{
System.out.println("NOT");
}
}
}
import java.io.*;
public class SQ2
{
public static void main(String[] args)throws IOException
{
String str;
int l;
str=str.trim();
str=' '+str;
l=str.length();
for(int i=0; i<l; i++)
{
if(str.charAt(i)==' ')
{
System.out.print(str.charAt(i+1));
}
}
}
}
import java.io.*;
public class SQ3
{
public static void main(String args[])throws IOException
{
String str;
int pos=0;
str=str.trim();
str=' '+str;
pos=str.lastIndexOf(' ');
for(int i=0; i<pos; i++)
{
if(str.charAt(i)==' ')
{
System.out.print(str.charAt(i+1)+".");
}
}
System.out.print(str.substring(pos+1));
}
}
//COMPUTER HARDWARE
// A-2, C-1, D-1, E-2, H-1, M-1, O-1, P-1, R-3, T-1, U-1, W-1
import java.io.*;
public class SQ4
{
public static void main(String args[])throws IOException
{
String str;
int l;
int c=0;
l=str.length();
for(int i=65; i<=90; i++)
{
for(int j=0; j<l; j++)
{
if(str.charAt(j)==i)
{
c++;
}
}
if(c>0)
{
System.out.println(c);
}
c=0;
}
}
str=str+' ';
l=str.length();
System.out.println("**************************");
for(int i=0; i<l; i++)
{
while(str.charAt(i)!=' ')
{
w=w+str.charAt(i);
i++;
}
int l2=w.length();
System.out.println(w+"-"+l2);
w="";
}
}
}
import java.io.*;
public class SQ6
{
public static void main(String[] args)throws IOException
{
String str;
int l;
int c=0;
str=str+' ';
l=str.length();
for(int i=0; i<l; i++)
{
if(str.charAt(i)==' ')
{
c++;
}
}
System.out.println("*******************");
System.out.println("COUNT OF SPACE: "+ c);
System.out.println("*******************");
for(int i=0; i<c; i++)
{
System.out.println(word[i]);
}
}
}
import java.io.*;
public class SQ7
{
public static void main(String args[])throws IOException
{
String str;
int l;
int x=65;
l=str.length();
import java.io.*;
public class SQ8
{
public static void main(String[] args)throws IOException
{
String str;
int l;
String S1="";
}
}
//"The quick brown fox jumps over the lazy dog" => user: The '2times'
import java.io.*;
public class SQ9
{
public static void main(String args[])throws IOException
{
String str="The quick brown fox jumps over the lazy dog";
str=str+' ';
int l = str.length();
String x;
int c=0;
System.out.println("*********************");
for(int i=0; i<c; i++)
{
System.out.println(arr_words[i]);
}
int c2=0;
for(int i=0; i<c; i++)
{
if(arr_words[i].equalsIgnoreCase(x))
{
c2++;
}
}
System.out.println("*********************");
System.out.println("Freq: "+ c2);
}
}
import java.io.*;
public class SQ10
{
public static void main(String args[])throws IOException
{
String str;
char c=' ';
int l, x;
String str2="";
l=str.length();
for(int i=0; i<l; i++)
{
c=str.charAt(i);
x=c;
if(x>=66 && x<=90 || x>=98 && x<=122)
{
x=x-1;
}
else if(x==65 || x==97)
{
x=x+25;
}
str2 = str2+(char)x;
}
System.out.println();
System.out.println("Original Str:"+ str);
System.out.println("Modified String:"+ str2);
}
}
import java.io.*;
public class SQ11
{
public static void main(String[] args)throws IOException
{
String str;
int l;
int x=0, y=0;