Ace Guy
Generating Random Numbers to Fill array. Java Beginner needing help!
0 Answer(s)      4 years and 10 months ago
Posted in : Java Beginners

Hello all! I am new to this site, and Java programming. My problem is: Write a program that produces random permutations of the numbers 1 to 10. eg. (1,4,7,10,2,9,8,3,6,5) or (10,7,9,2,1,3,6,5,4,8). My class needs to have the following methods: // Displays the array permutatedNumbers to the console public void displayPermutedArray(){} // Repeat the selection of a number 10 times to populate the permutated array public void generatePermutation(){} Make an array to hold the permuted numbers. Make a second array and fill it with the numbers 1 to 10 in order. Pick one of the numbers from the second array randomly, remove it, and write it to the permutation array. Repeat this 10 times. Test the functionality in your main method by calls to the generatePermutation() and displayPermutedArray() methods.

I am new to Java programming and this seems mind blowing to me :( I know how to create arrays and fill them with numbers entered. I will include a sample of how far my knowledge goes in this area to give you an idea of my skill level. The code I am including is a "sort" of tic-tac-toe I guess. I am writing on netbeans. On a side note I have never posted a code block before so If this does not display correctly I am extending an apology in advance! Thanks to all for the help!

import java.util.Scanner;

 * To change this template, choose Tools | Templates
 * and open the template in the editor.

 * @author Joe
public class TwoDArrayExamples {
    private char[][] board;
    public static void main(String [] args){
        TwoDArrayExamples twoD = new TwoDArrayExamples();
        Scanner scan = new Scanner(;
        char play = 0; 
        while (play != 'q') {
        System.out.println("Enter row and column to change and char to add");
    private void initializeArray(){
        board = new char [3][3];
        for(int row = 0; row < board.length; row++){
            for (int column = 0; column < board[row].length; column++){
                board[row][column] = '-';

    private void printArray(){
        for(int row = 0; row < board.length; row++){
            for(int column = 0; column < board[row].length; column++){
                System.out.print(board[row][column]+"  ");
    public void makePlay(int row, int col, String play ){
        board[row][col] = play.charAt(0); 


View Answers

Related Tutorials/Questions & Answers: