Advertisement
PadmaJS

Exercise 6.13

Sep 28th, 2022
3,070
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.53 KB | None | 0 0
  1. public class Exercise6_13 {
  2.   public static void main(String[] args) {
  3.     int random = Exercise6_13.getRandom(34, 35);
  4.     System.out.println(random);
  5.   }
  6.  
  7.   public static int getRandom(int... numbers) {
  8.     int randomNumber;
  9.     while (true) {
  10.       boolean match = false;
  11.       randomNumber = (int) (Math.random() * 53 + 1);
  12.       for (int i : numbers) {
  13.         if (i == randomNumber) {
  14.           match = true;
  15.           break;
  16.         }
  17.       }
  18.       if (!match) {
  19.         return randomNumber;
  20.       }
  21.     }
  22.   }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement