Question: C++ PROGRAMMING LANGUAGE!! I NEED HELP WITH THIS QUESTION b) Write definition of default constructor setting both numerator and denominator to 1. c) Write definition
C++ PROGRAMMING LANGUAGE!! I NEED HELP WITH THIS QUESTION b) Write definition of default constructor setting both numerator and denominator to 1.
c) Write definition of constructor with one parameter setting numerator to 1 and set denominator according to parameters given.
d) Write definition of constructor with two parameters setting numerator to first parameter and set denominator to second parameter.
e) Write definition of function setFraction() according to given prototype. That is, change instance variables to what provided in the parameters.
f) Write definition of function print() according to given prototype. Print instance variables with appropriate message, one per line.
g) Write definition of function getFraction() according to given prototype.
You should prompt for numerator and denominator and then set them respectively using values from the keyboard
h) Write your test program to test out some of the functions. It can be the one shown below
int main () {
Fraction f1;
f1.getFraction();
cout
f1.print();
f1.setFraction(2, 9);
cout
f1.print();
cout
return 0;
}
Write definition of function equal() according to given prototype. That is return true if two fractions are equal else return false.
j) Here is sample test code to test your equal() function.
int main () {
Fraction f1(1,2);
Fraction f2(1, 2);
Fraction f3 (3, 5);
if (f1.equal(f2)))
cout
else
cout
cout
if (f1.equal(f3))
cout
else
cout
cout
return 0;
k) Add a prototype for a value returning function called add() according to this UML prototype
+ add(const Fraction &) const : Fraction
l) Write implementation of the function add() according to given
prototype above. No need to simplify resulting fraction.
m) In main(), use code below to test your add() function.

Which is the correct result of adding fractions 1/5 and 3/4
n) Add a prototype to overload the + operator and also write its implementation.
After this overload, you should be able to have this:
f4 = f1 + f2;
Note that this is the same work done in part (o) above.
n) Test out the + operator on two Fraction objects in your test program.
o) Also overload the * operator so that two Fractions can be multiplied. Add code in your test program to test it out.
p) Also overload the >> operator so that you can prompt and read values to a Fraction object.
Note: This is the same task done in the function setFraction() Add code in your test program to test it out.
q) Also overload the
Note: This is the same task done in the function print() Add code in your test program to test it out.
76 int main() 78 79 80 81 82 83 84 86 87 Fraction f1(1,5); Fraction f2(3,4); Fraction f3; f3 = f1.add(f2); cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
