Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Q1 Program to print the reverse of any entered string.

import java.io.*;
public class reverse
{ public void array1() thros !"#$ception
{ %uffered&eader buff'ne %uffered&eader(ne !nput(tream&eader((ystem.in));
(ystem.out.println()#nter a string));
(tring a'buff.read*ine();
int l'a.length();
(ystem.out.print()the reverse string is ));
for(int i'l+1;i,'-;i++)
(ystem.out.print(a.char.t(i));
/
/
Q0 Program to arrange an entered string in .lphabetical order.
import java.io.*;
public class reverse
{
public void array1() thros !"#$ception
{ %uffered&eader buff'ne %uffered&eader(ne !nput(tream&eader((ystem.in));
(ystem.out.println()#nter a string));
(tring a'buff.read*ine();
int len'a.length();
for(int i'12;i3'4-;i55)
{
for(int j'-;j3l;j55)
{
char b'a.char.t(j);
int $'b;
if($''i 66 $''i570)
(ystem.out.print(b);
/
/
/
/
Q7 Program to input any string and display the voels 8 number of voels.
public class voels
{

public void voel((tring a)
{ int $9i;
for(i'-;i3a.length();i55)
{
char b'a.char.t(i);
if(b'':a: 66 b'':e: 66 b'':i: 66b'':o: 66 b'':u: 66 b'':.: 66 b'':#: 66 b'':!: 66b'':": 66 b'':;:)
{ $55;
(ystem.out.println(b);
/
(ystem.out.println($);

/
/
Q< Program to input a string and print each ord in reverse.
public class reverse
{

private int i9a19l9p9j;


public void reverse()
{
p'-; /

public void sample=ethod((tring str)
{str'str.trim();
l'str.length();
(ystem.out.print(str);
for(i'-;i3l;i55)
{
char a'str.char.t(i);

a1'(int) a;
if(a1''70 66 i''l+1)
{
for(j'i;j,'p;j++)
{
char b'str.char.t(j);
(ystem.out.print(b);
/
(ystem.out.print() ));
p'i;
/
/

/
/
Q2 Program to print the fre>uency of all the characters ithin a string.
public class fre>uency
{
private int i9a19l9p9j9fre>;

public fre>uency()
{
p'-;
fre>'-?

/

public void sample=ethod((tring str)
{
int ii;
l'str.length();
(ystem.out.print(str);
for(i'-;i3l;i55)
{
char a'str.char.t(i);
for(ii'-;ii3l;ii55)
{
char b ' str.char.t(ii);
if (a''b)
fre>'fre>51;
/
(ystem.out.println(a5) occurs )5fre>5) times));
fre>'-;
/
/
/
Q1 Program to print the characters of the string present at odd positions.
public class odd
{
private int $9i9l;
public odd()
{
$ ' -;
/
public void array1((tring a)
{
l'a.length();
(ystem.out.print()the characters of the string )5a5) at odd positions are?));
for(i'-;i3l;i55)
{
if (i@0A'-)
(ystem.out.print(a.char.t(i));/
/
/

You might also like