CSCI 689 Computer Assignment 8 A Class for Rational Numbers

$30.00

Category: Tags: , , , , You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (4 votes)

Write a C++ program to design and implement a class for rational numbers as outlined
in Chapter 6 of your textbook. In your implementation include the following member
and friend functions for this class:
 This constructor is used to
create a new object with the numerator and denominator If
it prints out an error message on but it doesn’t stop the execution of the
program. To reduce a number to its lowest terms, it calls the
member function: that returns the greatest common
divisor of the arguments and
 This copy constructor is used to create a new
object from the copy of the object
 This assignment operator
overwrites an existing object with the copy of the object

and
These four member functions overload the operators
and operators, respectively, for the class.
 and These two member
functions overload the pre–increment ( ) and pre–decrement ( )
operators, respectively, for the class.
 These two
member functions overload the post–increment (++) and post–
decrement ( ) operators, respectively, for the class. Note: To
differentiate between the pre– and post– versions of the operators ( ) and (
), an argument is included in the post– versions of these operators.

and
These four functions overload the
arithmetic operators and respectively, for the class.

2
and
These six functions
overload the relational operators and respectively, for the
class.
 This function
overloads the stream insertion operator ( ) for the class. It can be
used to print out the number with the numerator and
denominator as on the output stream and if it only
prints out
 This function overloads
the stream extraction operator ( ) for the class. It can be used to
read the number from the input stream where each Rational
number is given on a separate line with its three arguments: numerator,
separator ( ), and denominator, separated one or more white spaces. If a line
in does not contain a valid number, it prints out an error message
on but it doesn’t stop the execution of the program.
Put the definition of the class in the header file and the
implementations of its functions in the source file and at the top of your
source file, insert the statement:
A driver program is supplied to test your class. The source file of the driver
program is To use this source file, make a link from your program directory. To
compile the source files and and link their object files with the
system library routines, make a link to the from your program directory and then
execute: To test your program, execute: The files
and the are located in the directory: The input file
and the correct output file are also located in the same directory.
When your program is ready, mail its source and header files of your class to
your TA by executing: