Class Rational
- java.lang.Object
-
- Rational
-
public class Rational extends java.lang.Object
A class to represent a rational number with a numerator and denominator- Author:
- P. Conrad for CS56 F16
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
gcd(int a, int b)
greatest common divisor of a and bint
getDenominator()
int
getNumerator()
static int
lcm(int a, int b)
least common multiple of a and b hi scott :)static void
main(java.lang.String[] args)
For testing getters.static Rational
product(Rational a, Rational b)
Rational
times(Rational r)
java.lang.String
toString()
-
-
-
Method Detail
-
gcd
public static int gcd(int a, int b)
greatest common divisor of a and b- Parameters:
a
- first numberb
- second number- Returns:
- gcd of a and b
-
lcm
public static int lcm(int a, int b)
least common multiple of a and b hi scott :)- Parameters:
a
- first numberb
- second number- Returns:
- lcm of a and b
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getNumerator
public int getNumerator()
-
getDenominator
public int getDenominator()
-
main
public static void main(java.lang.String[] args)
For testing getters.- Parameters:
args
- unused
-
-