0

hi i need some help developing a rationaltest project in java.

```
package rationaltest;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class RationalDH extends Rational{
// fields
protected int top;
protected int bottom;
BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
public RationalDH(){
super();
}
public RationalDH(int numerator){
super(numerator);
}
public RationalDH(int numerator, int denominator){
super(numerator,denominator);
}
public RationalDH(Rational value){
super(value);
}
// accessor functions
public int ceil(){
// return numerator field of a Rational number
if (denominator() == 1){
//return top;
//return bottom;
}
return top;
}
public int floor(){
// return denominator field of a Rational number
return bottom;
//return top;
}
public int div(){
return top;
}
public int mod(){
return bottom;
}
// assignments
public RationalDH plusEquals(RationalDH right){
// return sum of two Rational numbers and
// assign value to this
RationalDH result = new RationalDH(
this.ceil() * right.floor() +
right.ceil() * this.floor(),
this.floor() * right.floor());
//this = result;
top = result.ceil();
bottom = result.floor();
return result;
}
// Greatest Common Divisor of a Rational number
int gcd(){
int n = top;
int m = bottom;
if (n==0){
return m;
}
if (m==0){
return n;
}
while (m!=n){
if (n>m){
n=n-m;
}else{
m=m-n;
}
}
return n;
}
public static void main(String args[]) {
Rational r = new Rational(-3,4);
RationalDH r1 = new RationalDH(7,3);
System.out.println("Abs of "+ r +" equals " + r.abs());
}
}
```

*Edited 3 Years Ago by pyTony*: fixed formatting