mercredi 30 novembre 2016

if block returning the same value no matter what

When i run the following code it always returns a 1 even when the rand variable is greater than 80.

public static void give(int oSquareType){

int rand = (int)(Math.random()*100+1);
oSquareType = 1;
System.out.println(rand);


 if(oSquareType == 1){
  if(rand >= 0 || rand < 81){
    System.out.println(1);
  }else if(rand>=81 || rand <= 85){
    System.out.println(2);
  }else if(rand>=86 || rand <=90 ){
    System.out.println(3);
  }else if(rand>=91 || rand <= 95){
    System.out.println(4);
  }else if(rand>=96 || rand <= 100){
    System.out.println(5);
  }
  }
}
}

dont know why it is doing this, help is much appreciated as always friends.

P.S. this code is just for troubleshooting purposes for one of my methods for a project which is having the exact same error.

Aucun commentaire:

Enregistrer un commentaire