Q1. Create a class called Rational for performing arithmetic with fractions. Write a program to test your class.
Use integer variables to represent the private data of the class – the numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it is declared. The constructor should contain default values in case no initialisers are provided and should store the fraction in reduced form. For example, the fraction 2/4, should be stored in the object as 1 in the numerator and 2 in the denominator. Provide public member functions that perform each of the following tasks:
• Adding two Rational numbers. The result should be stored in reduced form.
• Subtracting two Rational numbers. The result should be stored in reduced form.
• Multiplying two Rational numbers. The result should be stored in reduced form.
• Dividing two Rational numbers. The result should be stored in reduced form.
• Printing Rational numbers in the form a/b, where a is the nominator and b is the denominator.
• Printing Rational numbers in floating point format.
HI
Contact me for an efficient, perfect, well documented
development of your project according to 100% accuracy
and requirements, with dedicated support.
Thanks
Farah Saif
$20 CAD in 1 Tag
5,0 (57 Bewertungen)
5,2
5,2
5 Freelancer bieten im Durchschnitt $26 CAD für diesen Auftrag
Hi, its me again. I would like to work with you again if given the opportunity. I have read the requirements and I would like to do this project. Let me know if you are interested. Thanks.