Home Answers Viewqa Java-Beginners Question on reversing word of a sentnce

 
 


Raghavendra
Question on reversing word of a sentnce
1 Answer(s)      2 years and 4 months ago
Posted in : Java Beginners

Write a function that accepts a sentence as a parameter, and returns the same with each of its words reversed. The returned sentence should have 1 blank space between each pair of words. Demonstrate the usage of this function from a main program. Example: Parameter: ?jack and jill went up a hill? Return Value: ?kcaj dna llij tnew pu a llih?

View Answers

February 9, 2011 at 10:58 AM


Java Reverse words of sentence

import java.util.*;
public class ReverseString{
    public static void main(String[]args){
        Scanner input=new Scanner(System.in);
        StringBuffer buffer=new StringBuffer();
        System.out.println("Enter string: ");
        String str=input.nextLine();
        StringTokenizer stk=new StringTokenizer(str);
        while(stk.hasMoreTokens()){
            String st=stk.nextToken();
           String reverse = new StringBuffer(st).reverse().toString();
           buffer.append(reverse);
           buffer.append(" ");
        }
        System.out.println("Reverse: " + buffer.toString());
    }
}









Related Pages:
Question on reversing word of a sentnce
Question on reversing word of a sentnce  Write a function that accepts a sentence as a parameter, and returns the same with each of its words reversed. The returned sentence should have 1 blank space between each pair of words
reversing a string
reversing a string  how to reverse a string without using string function   class ReverseString { public static void main(String[] args) { String str="Hello World"; String st[]=str.split
question
question  dear sir/madam my question is how to compare two text format in java..we are java beginners..so we need the complete source code for above mentioned question...we have to compare each and every word
question
question  i have a project for search engine .i have a starting trouble , from where do i start project ,please help me.when i am given a key word to search ,which must return title,summary and url and i want to capture
Java Word Processor
Java Word Processor  Problem: Design and implement a class called... of words (a hyphenated word is one word), o number of sentences (ends in a period), o number of questions (ends in a question mark), o number
java word counting - Java Beginners
java word counting  Hi I want a code in java that replaces a word...... but this will change all the occurrence even if its part of another word the run......Please try to explain your question properly...import java.util.Scanner;public
Question In the Network ?
Question In the Network ?  Description Task: Joeâ??s Brokerage House currently has 25 standalone computers and five laser printers distributed... will run standard word-processing and spreadsheet programs. Use the worksheet
parsing word xml file using SAX parser - XML
parsing word xml file using SAX parser  i am parsing word 2003's XML file using SAX.here my question is,i want to write some tag elements which are between in other tag to a file. For ex
Reversing all root-to-leaf paths in a tree (JAVA) - Java Beginners
Reversing all root-to-leaf paths in a tree (JAVA)  A root-to-leaf path in a tree is defined to be a sequence of nodes starting from the root node... after reversing all root-to-leaf paths. For the following tree: root = 5
MicroSoft word
MicroSoft word  sir i want to develop an swing application like the microsoft word Document.can you help me pls
JSP Question - JSP-Servlet
JSP Question   hi i have different word and excel files in different pages.i want to store it in one workbook or print it in pdf format.hows this possible ? Thanks
JAVA Compile Question ?
JAVA Compile Question ?  I'm unable to compile this file and not sure why? Can someone please help? import java.nio.file.*; import...("The text file is " + ratio + "% of the size of the word file
Java Objectives Question
Java Objectives Question  Exercise 1: Create a file by using any word-processing program or text editor. Write an application that displays... and paste them into a word-processing program such as Word. Save the file
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
Question
Question   When there is an exception in my program how java runtime system handles
question
question  Dear sir i had some typing mistake at previous question so its my humble request to let me know the steps to start the tomcat6 under the tomcat directory
question
question  Gud morning sir, I have asked u some question regarding jsp in saturaday for that i didnot find any answere in which u send me the some of the links.U have asked me the specify some details. There is a entity name
Compare two word file
Compare two word file  How to compare two word file using Java
NUMBER OF VOWELS IN A WORD
NUMBER OF VOWELS IN A WORD  WRITE A PROGRAM THAT WILL INPUT A WORD THEN IT WILL DETERMINE THE NUMBER OF VOWELS PRESENT IN THE INPUTTED WORD
Write String in Word document
Write String in Word document  How to read and write strings in word document
Question?
Question?  My question is how to: Add a menu bar to the program with a File menu. In the File menu, add a submenu (JMenuItem) called About. When the user clicks on the About menu item, display a JOptionPane message dialog
Problem reading word file
Problem reading word file  Deepak you provide me code for extarcting equation from a word file and also to write in a word file.But when I again want to read preveously created word file(created by your code) it gives an error
open word document
open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link.... It will be helpful for you to read data from word document
open word document
open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link.... It will be helpful for you to read data from word document
open word document
open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link.... It will be helpful for you to read data from word document
how to delete a letter in a word?
how to delete a letter in a word?  how to delete a letter in a word? for example if i enter= roseindia, i want to delete 's', then output= roeindia