lundi 26 octobre 2020

lottery of a random number with 2 classes

I'm trying to create a lottery where a random number is generated (from 20-150) and the code says you won if the number generated is a number 40-50. However, I'm having problems calling my second class in my main method. I'm getting an error saying that "method draw in class Lottery cannot be applied to given types." How can I improve my code?

class Main {

Lottery.draw();

}


import java.util.*;

public class Lottery {
  public static void draw(String[] args) {
  int entry1 = (int)(Math.random()*150)+20;
  
  if(entry1>= 40 && entry1<=50){
    System.out.println("You won the lottery!");}
  System.out.println(entry1);
}
}




Aucun commentaire:

Enregistrer un commentaire