AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



corejava-string-handling: Translate English to Double Dutch

Write an application that encodes English language phrases into Double Dutch using the following algorithm: To form a Double Dutch sentence from an English sentence, translate each English word into a Double Dutch word, place the first letter of the English word at the end of the word and add the letters "ay." Thus the word "jump" becomes "umpjay," the word "the" becomes "hetay," and the word "ignite" becomes "gniteiay." Blanks between words remain as blanks. Assume that the English sentence consists of words separated by blanks, there are no punctuation marks and all words have two or more letters. Write a method printDutchWord that takes as input a word and returns the Double Dutch equivalent. The user inputs an English sentence to the program and the output is the Double Dutch equivalent printed on the screen. assume all letters are lowercase Input Specification: A line containing text to be converted. Output Specification: The double dutch text line. Sample input : this is ignite Sample Output : histay siay gniteiay

corejava x 352
string-handling x 34
Posted On : 2017-01-29 15:32:12.0
profile nav raj - anyforum.in nav raj
1200
up-rate
9
down-rate

Answers


import java.util.Scanner;

public class Translator {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println(englishToDoubleDutch(input.nextLine().split(" ")));
}

public static String englishToDoubleDutch(String[] input){
StringBuffer output=new StringBuffer();
for(String word:input){
output.append(printDutchWord(word)+" ");
}
return output.toString().trim();
}

public static String printDutchWord(String word){
return (word.length()>1?word.subSequence(1,word.length())+Character.toString(word.charAt(0))+"ay":word);
}
}

Posted On : 2017-01-30 00:20:34
Satisfied : 4 Yes  3 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523188221600
Reply This Thread
up-rate
10
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in