Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A. public class Frac { // constructor that takes 2 integer arguments, a numerator and denominator public Frac(int num, int denom) { // TODO: implement

A.

public class Frac {

// constructor that takes 2 integer arguments, a numerator and denominator

public Frac(int num, int denom) {

// TODO: implement this constructor

}

// constructor that takes a floating-point number and converts it into the appropriate rational number

public Frac(double d) {

// TODO: implement this constructor

}

// member function that converts the fraction to a floating-point number

public double toDouble() {

// TODO: implement this function

}

// member functions which implement the basic arithmetic operators for any two rational numbers

public Frac add(Frac other) {

// TODO: implement this function

}

public Frac subtract(Frac other) {

// TODO: implement this function

}

public Frac multiply(Frac other) {

// TODO: implement this function

}

public Frac divide(Frac other) {

// TODO: implement this function

}

}

Explanation:

B. public class Frac { // constructor that takes 2 integer arguments, a numerator and denominator public Frac(int num, int denom) { // TODO: implement this constructor } // constructor that takes a floating-point number and converts it into the appropriate rational number public Frac(double d) { // TODO: implement this constructor } // member function that converts the fraction to a floating-point number public double toDouble() { // TODO: implement this function } // member functions which implement the basic arithmetic operators for any two rational numbers public Frac add(Frac other) { // TODO: implement this function } public Frac subtract(Frac other) { // TODO: implement this function } public Frac multiply(Frac other) { // TODO: implement this function } public Frac divide(Frac other) { // TODO: implement this function } } C. public class Frac { // constructor that takes 2 integer arguments, a numerator and denominator public Frac(int num, int denom) { // TODO: implement this constructor } // constructor that takes a floating-point number and converts it into the appropriate rational number public Frac(double d) { // TODO: implement this constructor } // member function that converts the fraction to a floating-point number public double toDouble() { // TODO: implement this function } // member functions which implement the basic arithmetic operators for any two rational numbers public Frac add(Frac other) { // TODO: implement this function } public Frac subtract(Frac other) { // TODO: implement this function } public Frac multiply(Frac other) { // TODO: implement this function } public Frac divide(Frac other) { // TODO: implement this function } } D. public class Frac { // constructor that takes 2 integer arguments, a numerator and denominator public Frac(int num, int denom) { // TODO: implement this constructor } // constructor that takes a floating-point number and converts it into the appropriate rational number public Frac(double d) { // TODO: implement this constructor } // member function that converts the fraction to a floating-point number public double toDouble() { // TODO: implement this function } // member functions which implement the basic arithmetic operators for any two rational numbers public Frac add(Frac other) { // TODO: implement this function } public Frac subtract(Frac other) { // TODO: implement this function } public Frac multiply(Frac other) { // TODO: implement this function } public Frac divide(Frac other) { // TODO: implement this function } } E. public class Frac { // constructor that takes 2 integer arguments, a numerator and denominator public Frac(int num, int denom) { // TODO: implement this constructor } // constructor that takes a floating-point number and converts it into the appropriate rational number public Frac(double d) { // TODO: implement this constructor } // member function that converts the fraction to a floating-point number public double toDouble() { // TODO: implement this function } // member functions which implement the basic arithmetic operators for any two rational numbers public Frac add(Frac other) { // TODO: implement this function } public Frac subtract(Frac other) { // TODO: implement this function } public Frac multiply(Frac other) { // TODO: implement this function } public Frac divide(Frac other) { // TODO: implement this function } // method which reduces a fraction to its simplest form public Frac reduce() { // TODO: implement this function } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions