Results 1 to 3 of 3
  1. #1
    umaza is offline Member
    Join Date
    May 2012
    Rep Power

    Default Assignment help (String manupilation)

    I have an assignment in which you write a sentence and you have to convert any word within the sentence (String) that ends in "or" into "our", for example "color" into "colour"

    So if I input "My pant's color is yellow" it will output "My pant's colour is yellow"

    I don't understand how to do it.

    Condition for changing word is:
    if the word is more than four letters and
    if the word ends in "or" such that the letter before "or" is a consonant
    'Y' should be treated as a vowel

    My syntax so far:

    Java Code:
    import* ;
    public class IamCanadian
      public static void main (String[] args) throws IOException
        BufferedReader objReader = new BufferedReader (new InputStreamReader (; 
        String americanSentence;
        System.out.println("Input a sentence in an American dialect (press quit to exit)");
        americanSentence = objReader.readLine();
        Translation canadian = new Translation(americanSentence);
        String finalSentence = canadian.getCanuck();
        while (!(americanSentence.toLowerCase().equals("quit")));
    class Translation
      private String yankee;
      private String canuck; 
      Translation(String yankee)
        this.yankee = yankee;
      private void translate()
      String getCanuck()
        return canuck; 
    I have tried searching how to split String, but I always get results which have to do with arrays, which is the next lesson in school so we are not supposed to use array.
    I need to use indexOf, charAt, and substring. I have tried but always get something wrong.
    I don't know how to start in the translate method.

    Full Question for assignment is here

    @DarrilBurke - thanks, didn't know that

    Also, I solved it, all I needed to do was use the scanner class with StringBuffer, thanks anyway
    Last edited by umaza; 05-15-2012 at 11:55 PM. Reason: The problem was solved

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Assignment help (String manupilation)

    I don't know how to start in the translate method.
    Can you describe in small, simple steps (pseudo code) what the code should do?

    When you get the list of steps then you can start writing the code.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

Similar Threads

  1. Assignment Help
    By Albany in forum New To Java
    Replies: 6
    Last Post: 12-03-2011, 12:39 AM
  2. Can somebody help me in this assignment?
    By lulzim in forum New To Java
    Replies: 25
    Last Post: 03-02-2011, 12:02 AM
  3. Need help with a HW assignment
    By mackavelirip in forum New To Java
    Replies: 4
    Last Post: 02-17-2011, 02:36 AM
  4. Replies: 8
    Last Post: 05-15-2010, 05:05 PM
  5. Need with my assignment ...
    By allergy01 in forum New To Java
    Replies: 1
    Last Post: 04-25-2009, 09:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts