Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. Random rand = new Random();
  2. boolean poprawnyZakres = false;
  3. int min = 0;
  4. int max = 0;
  5.  
  6. System.out.println("Podaj zakres liczb:\nMin: ");
  7. min = skn.nextInt();
  8. System.out.println("Max:");
  9. max = skn.nextInt();
  10.  
  11. while(!poprawnyZakres){
  12.  
  13. if(min >= max){
  14. System.out.println("Niepoprawny zakres liczb");
  15. } else {
  16. poprawnyZakres = true;
  17. }
  18. }
  19.  
  20. int randomNum = rand.nextInt(max - (min-1))+1;
  21.  
  22. System.out.println(randomNum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement