Back
Close

Randomizer

JollyJungle
1,560 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
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants