0% found this document useful (0 votes)
6 views2 pages

EXPT

The document describes an experiment aimed at reversing the letters of each word in a given string using Java. It includes the code implementation for the task, which utilizes a Scanner to read input and processes the string to reverse each word. The output displays the new string after the reversal is completed.

Uploaded by

Wisdom wealth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

EXPT

The document describes an experiment aimed at reversing the letters of each word in a given string using Java. It includes the code implementation for the task, which utilizes a Scanner to read input and processes the string to reverse each word. The output displays the new string after the reversal is completed.

Uploaded by

Wisdom wealth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

REVERSE CHARACTER

EXPT.NO.14
Date:
Aim: To display the new string after reversing the letters of each word.
Coding:
import java.util.*;

public class reverse


{
public static void main (String args[])
{
String st,st1="",st2="";
int i,p;
char chr,chr1;
Scanner sc= new Scanner (System.in);
System.out.println("enter a String :");
st=sc.nextLine();
st=st+" " ;
p=st.length();
for (i=0;i<p;i++)
{chr=st.charAt(i);
if (Character.isWhitespace(chr)==true)
{
st2= st2+ " " +st1;
st1="";
}
else
st1=chr+st1;
}
System.out.println("the output:");
System.out.println(st2);
}
}

Output:

You might also like