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



Home Answers Viewqa Java-Beginners java word counting
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Hassan
java word counting
2 Answer(s)      6 years and 8 months ago
Posted in : Java Beginners


Hi I want a code in java that replaces a word with another when its occurred independently and ignores the case of the text... but this will change all the occurrence even if its part of another word the run


Advertisement
View Answers

April 10, 2008 at 3:31 PM


Hi
Execute the program and check whether is this what you want...Please try to explain your question properly...


import java.util.Scanner;


public class ReplaceLetters
{
public static void main(String[] args)
{
Scanner input;

input = new java.util.Scanner(System.in);

String s,s1,s2;
String resultString;
int count = 0,len;


System.out.print( "Enter a string: " );
s = input.nextLine();
System.out.println("enter the letter to be replaced(which yiou want to change)");
s1=input.nextLine();
System.out.println("enter the letter to replace(your own)");
s2=input.nextLine();
resultString=s.replace(s1,s2);
System.out.println("------ new string -----"+resultString);
}
}
Thanks
pinky


April 10, 2008 at 6:07 PM


Pinky,

Thank you very much that was great
but this will change all the occurance even if its part of another word
the run of this program must be like this

> Enter text to be changed : fat
> Enter text to change it with : xxxxxx
> Enter the original text line :
the fat boy and his father

output:
the xxxxxx boy and his father

while your program will output the following for the same inputs

>the xxxxxx boy and his xxxxxxher

thank you if you can help

Hassan


Related Tutorials/Questions & Answers:
java word counting - Java Beginners
java word counting  Hi I want a code in java that replaces a word with another when its occurred independently and ignores the case of the text... but this will change all the occurrence even if its part of another word the run
word and character counting - Java Beginners
word and character counting  here is the java code i made but i have to add something where it will read the inFile and display the number of words... = null; String word; int numLines = 0; int numWords = 0
Advertisements
letter counting for the smallest word
letter counting for the smallest word  How do I program my java... and it works EXCEPT that it counts all of the letters not just the smallest word...(); int count=ch.length; System.out.println("Count of smallest word
Counting specific word occurences in a file
Counting specific word occurences in a file  Hello I have a log file from the proxy which consists all the browsing history with date,time,url,ip address etc as fields.Now i need to take only main part of the url like the domain
Counting
Counting  Pl sir make a program which generate the following output on pop up menu. 1 12 123 1234 12345 123456 1234567 12345678 123456789   Java Print Pattern 1 12 123 1234 12345 123456 1234567 12345678 123456789
counting the positive,negative and zero nos. - Java Beginners
counting the positive,negative and zero nos.  Create a program that will input n number, and determine the number of positive, negative
counting identifiers,no.of inputs and outputs - Java Magazine
counting identifiers,no.of inputs and outputs  Hi, my name is jyothi.iam doing my miniproject the title is 'evaluation of complexity measure using... not getting....... plsssssss any one tell me it can be java for example #include
Counting the highest sequence of zeros and one's - Java Beginners
Counting the highest sequence of zeros and one's  Count the highest sequence value of '0's and '1's. for a given string with zeroes and ones. Input: You should ask user to enter any bit string with zeros and ones sequence
Easy Counting Java Program...Please Help? - Java Beginners
Easy Counting Java Program...Please Help?  As I said, I am a beginner at Java. I came across this problem that Im sure uses java. Could you please tell me the code to do this and possibly explain? How many ways
Word replacment - Java Beginners
Word replacment  Java code for the Word Replacement.Thnaks in Advance!  Hipublic class WordReplaced{ public static void main(String[] args... information,http://www.roseindia.net/java
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...: ? You can break up a String into words or "tokens" by using java?s Scanner
String file in to word file in java
String file in to word file in java  How to convert a String format notepad file into Ms word file in java
String file in to word file in java
String file in to word file in java  how to convert a String format word file into Ms Word file using java? please can anyone of you help me
word program - Java Beginners
word program  HELLO MAM AND SIR I ASK YOUR HELP HOPE YOU GONNA HELP ME THANK YOU!!Design a program to search a word for letters that the user... within the word a letter that the user entered,change the value of the array
PDF to Word Conversion - Java Beginners
PDF to Word Conversion  Hello, Can we convert a PDF document to Microsoft word document thru Java. If its not possible in Java, is it possible in any other language
java number to word - Java Beginners
java number to word  Can somebody please fix this to come out with the word, not the number 23? import java.util.Scanner; public class... { //----------------------------------------------------------------- // Pulls integers from a string to form a word
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
java code to open and display MS-word document
java code to open and display MS-word document  java code to open and display MS-word document
Java code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
export to word document - Java Beginners
export to word document  hi sir,when i am click on a button under the jtable,for example (print button),then i want to print that jtable in word document,automatically,plz provide program sir  Hi Friend, Try
create MS Word in Java - Java Beginners
which creates MS Word in Java...create MS Word in Java  Hi, Could any one please post the code which creates the word document having different paragraphs and two tables. i have
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.  **A program in JAVA which accepts a sentence & displays the longest word in the sentence along
Java word extraction program. - Java Beginners
Java word extraction program.  Need to code a public class named...- character word. The starting position should be based on the leftmost character... position and display the word on the console screen. Thanks
convert date month and year into word using java
;continue.... public void pass(int number) { int word, q...; if (word == 0) { q = number / 10...convert date month and year into word using java  convert the date
convert date month and year into word using java
;continue.... public void pass(int number) { int word, q...; if (word == 0) { q = number / 10...convert date month and year into word using java  convert the date
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Java Date Month Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year Java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
Advertisements
 

 

 

DMCA.com