문제
사용자가 입력한 단어에서 어근과 접미사를 구분하는 문제입니다 이를 해결하는 다음 프로그램에 대해 빈칸을 채우세요
-ly, -ment, -ance로 끝나는 단어를 입력하세요: lovely movement
lovely = love-ly
movement = move-ment
-ly, -ment, -ance로 끝나는 단어를 입력하세요: alignment variance kind proudly
alignment = align-ment
variance = vari-ance
kind = kind
proudly = proud-ly
-ly, -ment, -ance로 끝나는 단어를 입력하세요: kindly safely softly wisely
kindly = kind-ly
safely = safe-ly
softly = soft-ly
wisely = wise-ly
코드 빈칸 채우기
.;
public class Suffix
{
public static void main( String[] args ) {
scan = ( );
( "-ly, -ment, -ance로 끝나는 단어를 입력하세요: " );
input = scan.();
suffixes = { "ly", "ment", "ance" };
words = input.( " " );
( word words ) {
( word + " = " );
root = word;
( suffix suffixes )
root = root.( suffix, "" );
( root );
( suffix suffixes ) {
( word.( suffix ) ) {
int index = word.( suffix );
( "-" + word.( index ) );
;
}
}
}
scan.close();
}
}