목차
1. 요구사항
2. 설정
3. 프로그램소스
4. 결과화면
2. 설정
3. 프로그램소스
4. 결과화면
본문내용
t ("Translate another sentence (y/n)? ");
another = Keyboard.readString();
}
while (another.equalsIgnoreCase ("y"));
}
}
StringInverse.java
import java.util.StringTokenizer;
public class StringInverse
{
public int wordlength, wordvolume;
public String translate (String sentence)
{
String result = " ";
wordvolume=0;
sentence = sentence.toLowerCase();
StringTokenizer tokenizer = new StringTokenizer (sentence);
while (tokenizer.hasMoreTokens())
{
result += translateWord (tokenizer.nextToken());
result += " ";
wordvolume++;
}
return result;
}
public int word_aver (int length)
{
return (length/wordvolume);
}
private String translateWord (String word)
{
String result = "";
int i;
for ( i=0; i
result += word.substring(word.length()-i-1, word.length()-i);
return result;
}
}
another = Keyboard.readString();
}
while (another.equalsIgnoreCase ("y"));
}
}
StringInverse.java
import java.util.StringTokenizer;
public class StringInverse
{
public int wordlength, wordvolume;
public String translate (String sentence)
{
String result = " ";
wordvolume=0;
sentence = sentence.toLowerCase();
StringTokenizer tokenizer = new StringTokenizer (sentence);
while (tokenizer.hasMoreTokens())
{
result += translateWord (tokenizer.nextToken());
result += " ";
wordvolume++;
}
return result;
}
public int word_aver (int length)
{
return (length/wordvolume);
}
private String translateWord (String word)
{
String result = "";
int i;
for ( i=0; i
return result;
}
}
소개글