Question-1: Create A Class Rational Which Represents Two Data Members Num and Dnum With
Question-1: Create A Class Rational Which Represents Two Data Members Num and Dnum With
type integer. Create members function that gets the Num and Dnum from the user and
ShowRational () member function that displays the rational number in p/q format. Create a
default constructor that automatically sets the rational data members to 0 and 1. Create an
additional overloaded constructor for this class. This constructor receives integers as parameters
and assigns the values to the class data members. The class also includes a member function
AddRational (Rational, Rational) to add two rational objects. Create a main () function that
declared three objects of rational, add two rational no’s and then show the sum of two rational by
the main function. Demonstrates each function works correctly.
Question-2: Create a class called 'TIME' that has
- three integer data members for hours, minutes and seconds
- constructor to initialize the object to zero
- constructor to initialize the object to some constant value
- member function to add two TIME objects
- member function to display time in HH: MM: SS format
Write a main function to create two TIME objects, add them and display the result in
HH: MM: SS format.