how to place a character where it was after manipulating the string?
So I am doing a pig latin assignment, and lets say the user gives you "Car"
so the end result is "arCay" the original word, take first letter, put it
to the end, and add an "ay". i have done all this so far.
But i'm stuck at the punctuation part. How can I do it so that if the user
tells me "Car!" the end result will be "arCay!". For example, "!Hello!"
should be "!Ellohay!"
Code: [code][java]if(Character.isUpperCase(s.charAt(0))) {
if((s.charAt(0)==a2) || (s.charAt(0)==e2) || (s.charAt(0)==i2) ||
(s.charAt(0)==o2) || (s.charAt(0)==u2)) { if(s.contains(exc)) {
excMarkLocation=s.indexOf(excMark); s=s.replaceAll("[^a-zA-Z]", ""); temp2
= (s+"way"); s=temp2; s=s+'!'; } else { temp2 = (s+"way"); s=temp2;
}[/java][/code]
exc is the CharSequence "!" excMark is the char '!' excMarkLocation is
it's location
Sorry, what are the tags I should use?
No comments:
Post a Comment