jeudi 9 mars 2017

Randomly generated number of X's

I need a program to randomly generate a number, and then out put that number of x's, on there own line, until it outputs a line of 16 x's, and then it will stop. So far my program generates a number but never stops outputting. I'm sure this is my error but not sure what needs to change. Here is my code at this moment.

import java.util.Random;
public static void main(String[] args){
        toBinary();
        randomX();
    }

public static void randomX(){
    Random num = new Random();
    int ran = num.nextInt(16+1);
    int xs = ran;
    while(xs <= 16){
        System.out.print("x");
    }

}
}

Aucun commentaire:

Enregistrer un commentaire