Results 1 to 3 of 3
- 05-15-2012, 01:55 AM #1
Member
- Join Date
- May 2012
- Posts
- 4
- Rep Power
- 0
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:
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.Java Code:import java.io.* ; public class IamCanadian { public static void main (String[] args) throws IOException { BufferedReader objReader = new BufferedReader (new InputStreamReader (System.in)); String americanSentence; do { 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(); System.out.println(); System.out.println(finalSentence); } while (!(americanSentence.toLowerCase().equals("quit"))); } } class Translation { private String yankee; private String canuck; Translation(String yankee) { this.yankee = yankee; translate(); } private void translate() { } String getCanuck() { return canuck; } }
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
Edit:
@DarrilBurke - thanks, didn't know that
Also, I solved it, all I needed to do was use the scanner class with StringBuffer, thanks anywayLast edited by umaza; 05-15-2012 at 10:55 PM. Reason: The problem was solved
- 05-15-2012, 02:07 AM #2
Re: Assignment help (String manupilation)
Can you describe in small, simple steps (pseudo code) what the code should do?I don't know how to start in the translate method.
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.
- 05-15-2012, 06:53 AM #3
Re: Assignment help (String manupilation)
Why do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Assignment Help
By Albany in forum New To JavaReplies: 6Last Post: 12-02-2011, 11:39 PM -
Can somebody help me in this assignment?
By lulzim in forum New To JavaReplies: 25Last Post: 03-01-2011, 11:02 PM -
Need help with a HW assignment
By mackavelirip in forum New To JavaReplies: 4Last Post: 02-17-2011, 01:36 AM -
Need help with Assignment. [String splitting] [Full code provided]]
By jeanfrg in forum New To JavaReplies: 8Last Post: 05-15-2010, 04:05 PM -
Need with my assignment ...
By allergy01 in forum New To JavaReplies: 1Last Post: 04-25-2009, 08:33 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks