Here it is:
the user enters string and then then they enter a word from the sentnce they just entered in. then the program is supposed to take out the word they entered and then display the new sentence..

How to do this ????????
really need help PLEASE... :(

this is what i have so far...

import java.util.Scanner;
/**
*
*
*
*/
public class RemoveString {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner input=new Scanner(System.in);   

        String sent;
        String string;
        String part;

        System.out.println("Enter a sentence:");
        sent=input.nextLine();
        System.out.println("Enter a string:");
        string=input.nextLine();

    }
}

This case can have 2 cases.
1) Delete all the occurence of given word
2)Delete only a given occurence(mostly first) of given word

You have to split the input sentence using String.split() method. It will result into a array of Sring, containing all your words. Now compare all your words with the given input word. If a match is not there append the word into a StringBuilder along with a space. This will remove all the occuerence. If you want to delete a particular instance. Count the no of instance and break from the loop accordingly

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.