Question: Create this gui on java that supports rational calculations using this code as the logic, make it look like the picture below using JavaFX and

Create this gui on java that supports rational calculations using this code as the logic, make it look like the picture below using JavaFX and ComboBoxes for the operation options. Will thumbs up.
public class Rational extends Object implements Comparable {
private final int num;
private final int den;
public final static Rational ZERO = new Rational(0);
public final static Rational ONE = new Rational(1);
public int getNumerator(){
return num;
}
public int getDenominator(){
return den;
}
public Rational(){
this(0,1);
}
public Rational(int num){
this(num,1);
}
public Rational(int[] fract){
this(fract[0], fract[1]);
}
public Rational(int numerator, int denominator){
if (denominator ==0){
throw new ArithmeticException("denominator is zero");
}
int g = gcf(numerator, denominator);
if (denominator >0){
this.num = numerator / g;
this.den = denominator / g;
} else {
this.num =-numerator / g;
this.den =-denominator / g;
}
}
public Rational times(Rational b){
Rational a = this;
int num = a.num * b.num;
int den = a.den * b.den;
return new Rational(num, den);
}
public Rational plus(Rational b){
Rational a = this;
if (a.equals(Rational.ZERO))
return b;
if (b.compareTo(Rational.ZERO)==0)
return a;
int num = a.num * b.den + a.den * b.num;
int den = a.den * b.den;
return new Rational(num, den);
}
public Rational negate(){
return new Rational(-this.num, this.den);
}
public Rational minus(Rational b){
Rational a = this;
return a.plus(b.negate());
}
public Rational divides(Rational b){
Rational a = this;
return a.times(b.reciprocal());
}
public Rational reciprocal(){
return new Rational(this.den, this.num);
}
public Rational abs(){
if (this.num >=0)
return this;
else
return this.negate();
}
public double toDouble(){
return (double)this.num / this.den;
}
@Override
public boolean equals(Object obj){
if (this == obj)
return true;
if (obj == null)
return false;
if (this.getClass()!= obj.getClass())
return false;
Rational other =(Rational) obj;
if (den != other.den)
return false;
if (num != other.num)
return false;
return true;
}
public String toString(){
if (den ==1)
return num +"";
else
return num +"/"+ den;
}
public int compareTo(Rational b){
Rational a = this;
int lhs = a.num * b.den;
int rhs = a.den * b.num;
if (lhs rhs)
return -1;
if (lhs > rhs)
return 1;
return 0;
}
private static int gcf(int m, int n){
int retval =0;
if (m 0)
m =-m;
if (n 0)
n =-n;
if (n ==0)
retval = m;
else {
int rem;
while ((rem = m % n)!=0){
m = n;
n = rem;
}
retval = n;
}
return retval;
}
 Create this gui on java that supports rational calculations using this

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!