dimanche 6 juin 2021

How to write a java program to generate "odd", "random numbers" between 0 to 100 by using loops? [closed]

//The Code I wrote is this


import java.util.*;
class Example{
    public static void main(String args[]){
        Random input=new Random();
        int x;
        for(int i=0; i>-1; i++){
            x=input.nextInt(99)+1;
            int y;

            y= (x%2)=1?  x : x-1;//***is here any issue?*** 
            System.out.println(y);
        }
    }   
}

//Why can't I compile this? Is there any issue in "Ternary" part?




Aucun commentaire:

Enregistrer un commentaire