Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Raghavendra
Question on reversing word of a sentnce
1 Answer(s)      3 years and 11 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?


Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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
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
MicroSoft word
MicroSoft word  sir i want to develop an swing application like the microsoft word Document.can you help me pls
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
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
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
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
Write String in Word document
Write String in Word document  How to read and write strings in word document
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
Compare two word file
Compare two word file  How to compare two word file using Java
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
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
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
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
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
print word with max vowels
print word with max vowels  if suppose i hava entered a sentence and in that sentence i have to print a word which has maximum vowels in it.... i have tried it but i am not getting it...please help
finout longest word in sentence
finout longest word in sentence  write a program , how to find out the longest word in a sentence using java   Hi Friend, Try...; } } LongestWord(){ String word = ""; for(int i=0;i<stringArray.length;i++){ if(i==0
Reversing dojo slider to make it slide from right to left rather left to right as given
Reversing dojo slider to make it slide from right to left rather left to right as given  I am using Dojo slider in my project But i want to reverse the slider chosen value so that it slides from right to left ie the blueish part
com in ms word
com in ms word  how to use com object to fetch data from ms word and storing it into sql database
com in ms word
com in ms word  how to use com object to fetch data from ms word and storing it into sql database
Display the data to MS word
the database(say im searching using an id) and should display it on the ms word , i want it to be in a good format. FOr example my word doc has to be Name... a word doc would help a lot!! thank you
Scanning a word in a TEXT document......
Scanning a word in a TEXT document......  Hi Genius persons... I'm having many resumes in my FOLDER called HARISH in D:(colon) i want to scan... by searching the JAVA and .net words present in the files..if JAVA word is present means
Scanning a word in a TEXT document......
Scanning a word in a TEXT document......  Hi Genius persons... I'm having many resumes in my FOLDER called HARISH in D:(colon) i want to scan... by searching the JAVA and .net words present in the files..if JAVA word is present means
from number to word
from number to word  i want to know weather there is any method that can be use in changing value from number to word. Example if i write ten thousand, it will automatically be written as 10000.   Java convert 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
Advertisements
 

 

 

DMCA.com