I am using Netbeans and the goal is to make a program that allows the user to play a bean machine. The user chooses the number of slots in the machine and the number of balls dropped. The output is the direction each ball travels while in the machine (Right, left) at each intersection.

My question is, am i using the array correctly?
I am also suppose to print out the location of the bean, like if its in slot 1, 2,3,4 etc. I am not sure how to do that.



import javax.swing.JOptionPane;


public class Main {


public static void main(String[] args)
{
int balls = 0;
int slots = 0;
int location = 0;
int max_pegs = 0;
int left = 0;
int right = 0;
int counter = 0;
int location2;

int returned_num = 0;
String string_slots_elements;
String string_balls_elements;
char [] bean = new char [50000]; //Is this suppose to be new char [slots] or can i give it a big number as a placeholder

max_pegs = slots - 1;
string_slots_elements = JOptionPane.showInputDialog(null,
" number of slots?");
slots = Integer.parseInt(string_slots_elements);
string_balls_elements = JOptionPane.showInputDialog(null,
" number of balls dropped?");
balls = Integer.parseInt(string_balls_elements);
while (counter < balls) {
for (int i = 0; i < slots; i++){
for (int k = 0; k < balls; k++)
{
//System.out.print(k);

}
returned_num = get_random_number_for_LEFT_RIGHT();
if (returned_num == 0){
System.out.print("L");
//location = location;
left++;

}
else if(returned_num == 1){
System.out.print("R");
//location2 = location + 1;
//bean[location2] = 'O';
right++;
}

}
bean[counter] = (char) location;


System.out.println();
counter++;
}
//System.out.print(returned_num);
}
private static int get_num_elements_of_array()
{
int slots = 0;
String string_slots_elements;
string_slots_elements = JOptionPane.showInputDialog(null, " number of elements in the array?");
slots = Integer.parseInt(string_slots_elements);

return slots;
}
//------------------------------
private static int get_num_balls_dropped()
{
int balls = 0;
String string_balls_elements;
string_balls_elements = JOptionPane.showInputDialog(null, " number of balls dropped?");
balls = Integer.parseInt(string_balls_elements);

return balls;
}

//------------------------------
private static int get_random_number_for_LEFT_RIGHT()
{
int num;
num = (int)(0 + Math.random() * 2);

return num;
}

}