Advertisement
mmayoub

RunRational.java

Jan 28th, 2023
834
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class RunRational {
  4.  
  5.     public static void main(String[] args) {
  6.         Random rnd = new Random();
  7.         int a, b;
  8.  
  9.         a = rnd.nextInt(100);
  10.         b = 1 + rnd.nextInt(100);
  11.  
  12.         Rational r = new Rational(a, b);
  13.         System.out.println(r);
  14.  
  15.         a = rnd.nextInt(100);
  16.         b = 1 + rnd.nextInt(100);
  17.  
  18.         Rational r1 = new Rational(a, b);
  19.         System.out.println(r1);
  20.  
  21.         while (!r.isEqual(r1)) {
  22.             a = rnd.nextInt(100);
  23.             b = 1 + rnd.nextInt(100);
  24.  
  25.             r1 = new Rational(a, b);
  26.             System.out.println(r1);
  27.         }
  28.         System.out.println("**********************");
  29.         System.out.println(r);
  30.         System.out.println(r1);
  31.  
  32.     }
  33.  
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement