View Single Post
  #1 (permalink)  
Old 07-31-2007, 05:12 AM
zoe zoe is offline
Member
 
Join Date: Jul 2007
Posts: 40
zoe is on a distinguished road
Displaying numbers per line on a JOptionPane.showMessageDialog screen
Hi, 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
Code:
If (count % 5 == 0); temp = temp + "/n";
maybe?

Here is what I have at the moment. I am really stuck on how to implement the return character.
Code:
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); } }
Thanks.
Reply With Quote
Sponsored Links