| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 07/20/2010 17:07:30
|
Lass88
Newbie
Joined: 07/20/2010 16:56:49
Messages: 2
Offline
|
For a homework assignment I have to write a program that takes 6 letters, puts them in an array and prints the letters in the array in a random order. For example I have [t, y, u, i, f, d] in my array and when I put it through my random method it will give me [y, d, t, u, f, i] or some other random order of these letters. I am also suppose print out all of the possible strings of these 6 letters exactly once and I am having a hard time figuring out how to do it. I figure that I am suppose to put it in a loop that compares the arrays it has already come up with to the new one to see if it is different and when it can't come up with a different array to exit the loop, but I have no idea how to write it. Any help is greatly appreciated, thanks!
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 07/21/2010 07:46:37
|
stdunbar
Newbie
![[Avatar]](/images/avatar/a87ff679a2f3e71d9181a67b7542122c.png)
Joined: 06/22/2005 14:51:37
Messages: 849
Location: Superior, CO, USA
Offline
|
What code do you have now? I'd think that you want one or more loops to do this. The hard part is keeping track of what has been already generated to make sure you don't generate it again.
|
Thanks for using the forums at hotjoe.com |
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 07/21/2010 08:32:26
|
Lass88
Newbie
Joined: 07/20/2010 16:56:49
Messages: 2
Offline
|
OK, this is my class:
import java.util.Random;
And this is my main:
The out put I get right now is [a, t, g, o, d, c] or some other one random version of the array.
|
|
|
 |
|
|
|
|