Back
Close

Randomizer

JollyJungle
4,014 views

Randomizer

I'm not sure why this doesn't work, please tell me in comments.

import java.util.Random; 

public class Main {
    


public static void main (String[] args) {
    Random rand = new Random();

    int  a = rand.nextInt(10) + 1;
    
    String name = "Viewer";
    if (a + 3 <= 10) {
    
    System.out.println("Hello " + name + "!");
    }
    else {
        System.out.println("Goodbye " + name + "!");
    }
}
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io