Define a class for rational numbers a rational number is a


Problem

Define a class for rational numbers. A rational number is a number that can be represented as the quotient of two integers. For example, 1/2, 3/4, 64/2, and so forth are all rational numbers. (By 1/2 and so on we mean the everyday fraction, not the integer division this expression would produce in a C++ program.) Represent rational numbers as two values of type int, one for the numerator and one for the denominator. Call the class Rational. Include a constructor with two arguments that can be used to set the member variables of an object to any legitimate values. Also include a constructor that has only a single parameter of type int; call this single parameter whole Number and define the constructor so that the object will be initialized to the rational number whole Number/1. Include a default constructor that initializes an object to 0 (that is, to 0/1). Overload the input and output operators >> and <=,>, >=, +, -, *, and /. Write a test program to test your class.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Define a class for rational numbers a rational number is a
Reference No:- TGS02745823

Expected delivery within 24 Hours