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");
}
}
}