Question: Modify this code to answer the questions below in C++ #include #include #include using namespace std; class RationalNumber { public: RationalNumber(): RationalNumber(0, 1) { }
Modify this code to answer the questions below in C++
#include
class RationalNumber { public: RationalNumber(): RationalNumber(0, 1) { } RationalNumber(int n): RationalNumber(n, 1) { } RationalNumber(int n, int d); int getNumerator() const { return numerator; } int getDenominator() const { return denominator; } void setNumerator(int n) { numerator = n; } void setDenominator(int d) { denominator = d;} void output() const { cout
RationalNumber::RationalNumber(int n, int d) { if(d == 0) { cout
int main() { RationalNumber r1{12, 18}; cout

6. Copy the code from Example 4.10_RationalNumber.cpp to a new program. a. Implement Euclid' s algorithm for the Greatest Common Divisor as a static function that accepts two integers and returns the GCD Euclid' s Algorithm (Iterative pseudo code) Given two integers, a and b: while b !0 tempa b temp % b return a b. Verify that both functions are working properly . Augment the code in problem 6. a. Implement a Least Common Multiple algorithm as a static function that accepts two integers and returns the LCM b. Implement a reduction function that uses the GCD to reduce a fraction to it' s simplest values c. Verify that both functions are working properly
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
