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