TheKick
07-05-2005, 01:11 AM
Ok I am new to Java and am trying to nail down use of loops. I am trying to have my program output all the even numbers from 0-500 displaying 5 numbers per line on a JOptionPane.showMessageDialog screen. I can get it to output one number each output box but you need to keep hitting ok. I was thinking of using modulus in an if loop.
Something like
If (count % 5 == 0);
temp = temp + "/n";
mabey?
Here is what I have at the moment. I am really stuck on how to implement the return character.
import javax.swing.JOptionPane;
public class Counting
{
public static void main(String args[])
{
String temp;
int count=0;
while (count <= 400)
{
JOptionPane.showMessageDialog(null, "The output is "+ count);
count = count + 2;
}
if (count % 5 == 0);
temp = temp + "/n";
System.exit(0);
}
}
Something like
If (count % 5 == 0);
temp = temp + "/n";
mabey?
Here is what I have at the moment. I am really stuck on how to implement the return character.
import javax.swing.JOptionPane;
public class Counting
{
public static void main(String args[])
{
String temp;
int count=0;
while (count <= 400)
{
JOptionPane.showMessageDialog(null, "The output is "+ count);
count = count + 2;
}
if (count % 5 == 0);
temp = temp + "/n";
System.exit(0);
}
}