Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: how do i make my program to....

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how do i make my program to....

    Ask the user for a word to find in the text. Then display all the text in lower case, except for the target word, which should be in upper case. Also display how many times the target word was found.

    can someone give me some direction on how to go about this


  2. #2
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: how do i make my program to....

    Hey Andys,

    I'd recommend you have a look a Regex and Java Pattern & Matcher classes. They will allow you to implement a good search method using a simple regex string.

    You can then use this to count matches and reformat your text.

    Chris

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: how do i make my program to....

    This should help you start..

    import java.io.File;
    import java.util.Scanner;
     
    public class WordFinder {
     
        /**
         * JavaProgrammingForums.com
         */
        public static void main(String[] args) {
            System.out.println("Enter word to find: ");
            Scanner sc = new Scanner(System.in);
            String word = sc.next();
            readFile(word);
        }
     
        public static void readFile(String word) {
     
            // Location of file to read
            File file = new File("data.txt");
     
            // File reading code
     
        }
     
    }

    Tale a look at:

    http://www.javaprogrammingforums.com...ner-class.html
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. how do i make my program to do......
    By andys in forum Object Oriented Programming
    Replies: 6
    Last Post: November 29th, 2010, 07:44 AM
  2. How To Make The Program Jump To The Next Function..
    By Kumarrrr in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 3rd, 2010, 12:33 AM
  3. how to make a program take time...
    By DLH112 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 10th, 2010, 07:09 PM
  4. Help with a program to make a landscape picture
    By noseeds in forum Java Theory & Questions
    Replies: 1
    Last Post: December 15th, 2009, 10:25 PM
  5. Java program to write game
    By GrosslyMisinformed in forum Paid Java Projects
    Replies: 3
    Last Post: January 27th, 2009, 03:33 PM