public class IamCanadian {
  
 public static void main (String[] args) {
      // create an object, and
      IamCanadian canEng = new IamCanadian ();
      // while the user does not enter "quit" as a sentence:
      // get a string from the user 
      System.out.println ("enter a American English");
      String ameEng = ReadLib.readString ();
      // set the text of the object to the user string 
      // translate the American String to Canadian 
      // display the translated sentence
      System.out.println (canEng.getCanuck());
      } // end of main method.

public class Translation {

   private String yankee;
   private String canuck;

   public Translation() {
      } // end of constructor

   public void translate() {
      } // end of method translate

   public String getCanuck() {
      return ""; // this line will need to be changed to return the translated string.
      } // end of method getCanuck

} // end of class Translation

i just started a java i don't know lot much about it so i need help with this problem
the question is:
Americans spell some words differently from Canadians. Americans write "neighbor" and "color" while Canadians write "neighbour" and "colour". You are going to write the Translation class that will contain two Strings called canuck and yankee. The yankee String will contain an American sentence and the canuck String, the Canadian version.
The Translation class will be defined as follows:

Data Members:
private String yankee;
private String canuck;
Methods:

public Translation()
public void translate()
public String getCanuck()

The translate() method is the most complicated, it will separate each sentence into words, translate each word from American to Canadian and reconstruct the sentence in Canadian. You may wish to write another method to break the task down into several smaller tasks.

The rules for converting a word to Canadian are as follows:


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
You will write the IamCanadian class that it will contain the main() method. The main method should:

create an object, and

while the user does not enter "quit" as a sentence:

get a string from the user
set the text of the object to the user string
translate the American String to Canadian
display the translated sentence

Recommended Answers

All 3 Replies

And your question is?

No one is going to do your homework for you. Not only do we not condone cheating, but it is against the terms and conditions you agreed to when you created an account here.

public class IamCanadian {
  
 public static void main (String[] args) {
      // create an object, and
      IamCanadian canEng = new IamCanadian (ameEng, canEng);
      // while the user does not enter "quit" as a sentence:
      // get a string from the user 
      System.out.println ("enter a American English");
      String ameEng = ReadLib.readString ();
      // set the text of the object to the user string 
      // translate the American String to Canadian 
      // display the translated sentence
      System.out.println (canEng.getCanuck());
      } // end of main method.

public class Translation {

   private String yankee;
   private String canuck;
   private char word;
   char [] alphabet = ('a', 'b', 'c', 'd', 'e', 'f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');

   public Translation(int us, int ca, char alpha) {
     yankee = us;
     canuck = ca;
     alpha = word;
     translate ();
      } // end of constructor

   public void translate() {
     if (word > 4)
     {
       
      } // end of method translate

   public String getCanuck() {
      return canuck; // this line will need to be changed to return the translated string.
      } // end of method getCanuck

} // end of class Translation

sorry for doing that but i was just try to show what is the problem to solve and im not asking for you guys to do my homework im just new at this so im just try to get some help i don't want the whole answer
then i will ask a question
i think i have to use a stringbuffer but i don't know where to use it

i think i have to use a stringbuffer but i don't know where to use it

In the translate method - and use StringBuilder instead of StringBuffer.

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.