C++: im having trouble with this. i need help!
1. Write the class of a class called Fraction using the UML given below. The name of the class must be called Fraction.h Fraction numerator int denominator int +Fraction +Fraction (int, int) Numerator (num int) void. +set +set Denominator (num int) void +getNumerator int const +get Denominator int const +print void Remember to use #ifndef Macro to guard against multiple inclusion. Refer to the powerpoint in how to define the macro 2. Write the definition of constructors and functions for the Fraction class in a file called Fraction. cpp Note for the print function, print the numerator and denominator separated by a slash Remember that you must have a statement for include \"Fraction. h\" in the Fractions .cpp file For the print function print the numerator and denominator separated by a slash Write your test program (with the main function) with a name of your choice to make use of the Fraction class Remember that you must have a statement for #include Fraction.h\" in this file 5. In your main function write code to declare two Rectangle objects called f1 and f2
#include
using namespace std; class fraction { private: int numerator; int denominator; public: fraction (); //default constractor....check fraction (int,int); //default constractor with parameters ....check fraction AddedTo (fraction value) const; fraction MultipliedBy (fraction value) const; //binary observer type of operation fraction Subtract (fraction value) const; fraction DividedBy (fraction value) const; fraction isGreaterThan (); fraction isEqualTo (); fraction print() const; }; #include using namespace std; int main() { int frArray[3]={5,6,2}; fraction f1(frArray[0],frArray[1]); //calling a parameterized class constructor fraction f2(frArray[1],frArray[2]); //calling a parameterized class constructor fraction result; //calling a default class constructor fraction f3; //calling a default class constructor cout << \"The result starts off at \"; result.print(); //calling an observer function cout << endl; cout << \"The product of \"; f1.print(); cout << \" and \"; f2.print(); cout << \" is \"; result = f1.MultipliedBy(f2); //a class binary operation - function result.print(); cout << endl; f3 = result; //assignment /* if (f2.isGreaterThan(f3)){ //a class relational expression - boolean operation/function f2.print(); cout <<\" is greater than \"; f3.print(); cout<fraction2; } //************************************* bool fraction::isEqualTo(fraction value) { (numerator/denominator)==(value.numerator/value.denominator); } //************************************** fraction fraction::print() const { int num=numerator; int den=denominator; if(num>den) { for(int counter=2;counternum) { for(int counter=2;counter