0
프로그램이 특정 문장의 끝 형식을 찾습니다. 의 선언적, 감탄적 또는 의문이든 여부. 그러나 대화 상자를 구성하는 데 문제가 있습니다. 또한 if 문장이 올바른 응답을 반환하도록 올바르게 구성되었는지를 확신 할 수 없습니다.Dialogbox의 indexOf를 사용하는 If 문을 사용하면
import javax.swing.JOptionPane;
public class P45
{
public static void main(String [] args)
{
String s = JOptionPane.showMessageDialog("Please input sentence.");
if (s.indexOf('!')!=0){
JOptionPane.showMessageDialog(null, " Sentence is exclaimatory");
}
else if (s.indexOf('.')!=0){
JOptionPane.showMessageDialog(null, " Sentence is a statement");
}
else if (s.indexOf('?')!=0){
JOptionPane.showMessageDialog(null, " Sentence is a question");
}
}
}