title: if condition used with JOptionPane showMessageDialog
body: <p>The code below when run generates only the name of the last student with marks&lt;30 I want all the names of the student to be displayed in the same message dialog box. Please help. Thanks and I'm fairly new to coding.</p>
  
  <pre><code>import javax.swing.JOptionPane;
  class marks
  {
      public static void main(String args[])
      {
      String name=" ";
      int marks=0;
  
      for(int x=0; x&lt;3; x++) 
          {
          name=JOptionPane.showInputDialog(null,"Please enter the name");
          marks=Integer.parseInt(JOptionPane.showInputDialog(null,"Please enter the marks"));
          }
  
      if (marks&lt;30)
              {
          (JOptionPane.showMessageDialog(null,"the students who got marks below 30 are: "+name));
          }
      }
  }
  </code></pre>