#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    1
    Rep Power
    0

    Single nouns into plural string... Pls help...


    When entering any noun, I have to change it into plural form.
    This is the example what needs to be shown on screen is this:

    enter a noun: wolf
    Plural noun of wolf is wolves

    These are the four rules:
    1)for nouns ending with "y", have to delete "y" and put "ies"
    2) for nouns ending with "f", have to delete "f" and put "ves"
    3) for nouns ending with "s", "ch", "sh", have to put "es"
    4) for nouns with none of the above put "s"

    I have no idea how to start the coding...
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,710
    Rep Power
    480
    Your program will need a place to store the input.
    What data type is appropriate?

    "enter a noun" The program will interact with its master.

    Is the entry one word at a time? Does the program need to read entire books and parse them for likely nouns? (Probably not.)

    Can you write code to find the end of a word?

    How about a main function to drive the project?


    Make an outline, then fill in these details with code.
    Consider leaving the outline in the program as your "program comments".

    Code:
    main
      forever
    
        get word, maybe with a prompt.
    
        /* check for finished */
        if done, indicated by word length of 0 or end of file, perhaps
          break
    
        find the last character of the word
        if rule 1 applies take that action and continue the forever loop.
        if the second rule applies take that action and continue the forever loop.
        if rule 3 applies---careful!
          Make sure the word is long enough to back up 2 positions from the end.
          continue
        write the word and also 's'
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo