Forums Register Login

How to use a for loop or any iteration in JOptionPane message dialogue?

+Pie Number of slices to send: Send
Hello Java developers.
I would like to ask what is the code or what to do to show the result of a for loop (or just any other iterations) in a JOptionPane message dialogue box?

Here is the code, and I want to show the factored numbers in a JOptionPane message dialogue box..
http://pastebin.com/kCySiviv

Any help is appreciated

Jaypee
+Pie Number of slices to send: Send
Welcome to the Ranch

We do not simply provide complete solutions; please post the code here, and we'll have a look at it. You seem to have a factorial program. What do you need to show on an option pane?
+Pie Number of slices to send: Send
Sorry sir, my bad for posting a link.
Here's my factorial code in java:



I want to stress out this code:

where it should be an output in a JOptionPane message dialogue and not in the console.

Thank your sir for the help and for upcoming solutions

Cheers,
Jph
+Pie Number of slices to send: Send
That isn't a factorial program: don't call the method factorial2.
Don't use shorts (or Shorts) for arithmetic. Use ints.
What do you expect if you factorise 480?

Do you mean something like appending the numbers to create a String something like this?

Factors of 128: 1 2 4 8 16 32 64 128

I think 1 does not count, just as 1 doesn't count as a prime number.
Are you aware of the StringBuilder class, or the new StringJoiner which adds a separator between successive values? I think those might help. Note those underlined words are links.
+Pie Number of slices to send: Send
Thank for those who've comment.

I resolved this issue on my own and must now be closed.

The code that I've applied is that, I used a String on which I've stored the strings to be appended and to be finally posted in the message dialogue box and engaged it in the iteration process to create a storing method.
Anyways, thank you for your comments and it is very much appreciated by me.

Cheers,
Jph
+Pie Number of slices to send: Send
 

John Paul Hernandez wrote:I resolved this issue on my own and must now be closed.

Well done.

I hope you got separate method to do so, rather than one "main" method to do everything.
There are more ways to do it, but one could look simply like this:
+Pie Number of slices to send: Send
Shorter:JOptionPane is array-aware.
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 6802 times.
Similar Threads
Iterative Development
The Guessing Game - Java
Divisor or prime problem
Recursive method to print prime factorization of a number
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:49:59.