以下のコードを実行すると、マークが 30 未満の最後の生徒の名前のみが生成されます。生徒のすべての名前を同じメッセージ ダイアログ ボックスに表示したいと考えています。助けてください。ありがとう、私はコーディングにかなり慣れていません。
import javax.swing.JOptionPane;
class marks
{
public static void main(String args[])
{
String name=" ";
int marks=0;
for(int x=0; x<3; x++)
{
name=JOptionPane.showInputDialog(null,"Please enter the name");
marks=Integer.parseInt(JOptionPane.showInputDialog(null,"Please enter the marks"));
}
if (marks<30)
{
(JOptionPane.showMessageDialog(null,"the students who got marks below 30 are: "+name));
}
}
}