mercredi 26 septembre 2018

Printing random even value between two values using inheritance

I am trying to print a list of random even numbers (5 times) using a bounds. Example being from 0 to 30 (including both those numbers). This is what I have so far (this is in its own class):

public int nextEven(int h){
        int n = rand.nextEven(h) % 2;
        return n;
        }

This is where it would print from my main method:

System.out.println("Random Even:");
    for (int i = 0; i < 5; i++){
        System.out.println(rand.nextEven(30));
    }

When I run the program it gives me an error and I am not quite sure how to solve this. This is an example of the desired output of even numbers from 0 to 30:

4 26 12 10 20




Aucun commentaire:

Enregistrer un commentaire