New to java
I'm trying to take string elements inside of an array and pair them with a random number and have it print to the console each time it runs.
For instance the letters B, I, N, G, O, X are stored in the array. I set the math.random out put to a max of 30.
I'm trying to get it to print out one random alphanumeric character starting with a char and ending with a one or two digit int.
Just not sure how to form this.
import java.util.Random;
public class BingoXgame {
public static void main(String[] args) {
//BINGOX LETTER ARRAY
String [] letter = new String [6];
letter [0] = "B";
letter [1] = "I";
letter [2] = "N";
letter [3] = "G";
letter [4] = "O";
letter [5] = "X";
//Generates random number between 0 and 30
int num = (int)(Math.random()*30);
//takes the random letter and number from single run through and creates a
random alpha numeric string.
System.out.println(letter.random()+num);
}
}
Aucun commentaire:
Enregistrer un commentaire