Java Please Assignment Re Going Create New Class Named Fraction Managing Rational Numbers Q37058450

***IN JAVA PLEASE***

For this assignment, you’re going to create a new class named“Fraction” for managing rational numbers (fractions). (You shouldnot submit a main program with the Fraction class; however, you’lldefinitely want to write one for your own testing purposes.)Details are as follows:

CLASS DEFINITION

CONSTRUCTORS:

Fraction(int num,int denom)creates a new number whose value isnum/denom

Fraction(int num)creates a new number whose value is num/1

METHODS (assume x is a Fraction):

Fraction x.add(Fraction n)Returns x+n in reduced form

Fraction x.sub(Fraction n)Returns x-n in reduced form

Fraction x.mul(Fraction n)Returns x*n in reduced form

Fraction x.div(Fraction n)Returns x/n in reduced form

double x.toDouble()Returns x as a double-precision

floating point number

int getNum(),int getDenom()Returns numerator or denominator

String

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.