Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. package test;
  2.  
  3. public class Util {
  4.  
  5. public static void sayMyName(String name) {
  6. System.out.println("My name is " + name);
  7. }
  8.  
  9.  
  10. public static void print(int i) {
  11. System.out.println(i);
  12. }
  13.  
  14. public static void print(String str) {
  15. System.out.println(str);
  16. }
  17.  
  18. public static int rand(int h) {
  19. int x = 0;
  20. x = (int)(Math.random() * ++h);
  21. return x;
  22. }
  23. /**
  24. * Return random value from L to H
  25. * @param l
  26. * @param h
  27. * @return
  28. */
  29. public static int rand( int l, int h) {
  30. int x = 0;
  31. x = (int)(Math.random() *(h - l) + l);
  32. return x;
  33. }
  34. public static int randV2( int start, int end) {
  35. int result = start +
  36. (int) (Math.random() * (end - start + 1));
  37. return result;
  38. }
  39.  
  40. public static int randV3( int lowBound, int highBound) {
  41. int num = (int) ((Math.random() *
  42. (highBound - lowBound + 1)) + lowBound);
  43. return num;
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement