Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE MAKE THESE TWO FILES: RationalNumber.h (class specification file) RationalNumber.cpp (class implementation file) HERE IS app_prog1.cpp #include #include RationalNumber.h using namespace std; int main() {

PLEASE MAKE THESE TWO FILES:

RationalNumber.h (class specification file)

RationalNumber.cpp (class implementation file)

image text in transcribed

HERE IS app_prog1.cpp

#include

#include "RationalNumber.h"

using namespace std;

int main()

{

RationalNumber c( 7, 3 ), d( 3, 9 ), x;

c.printRational();

cout

d.printRational();

cout

x = c + d; // test overloaded operators + and =

x.printRational();

cout

c.printRational();

cout

d.printRational();

cout

x = c - d; // test overloaded operators - and =

x.printRational();

cout

c.printRational();

cout

d.printRational();

cout

x = c * d; // test overloaded operators * and =

x.printRational();

cout

c.printRational();

cout

d.printRational();

cout

x = c / d; // test overloaded operators / and =

x.printRational();

cout

c.printRational();

cout

// test overloaded greater than operator

cout d ) ? " > " : "

d.printRational();

cout operator ";

// test overloaded less than operator

cout = " );

d.printRational();

cout

// test overloaded greater than or equal to operator

cout = d ) ? " >= " : "

d.printRational();

cout = operator ";

// test overloaded less than or equal to operator

cout " );

d.printRational();

cout

// test overloaded equality operator

cout

d.printRational();

cout

// test overloaded inequality operator

cout

d.printRational();

cout

cin.get();

// system("PAUSE");

return 0;

} // end main

For this programming assignment you will be implemented a RationalNumber class. In mathematics, a rational number is a number that can be represented as a fraction, where both the numerator and the denominator in the fraction are integers (i.e., whole numbers). Every integer is a rational number, because the denominator in the fraction can be 1 (i.e., 7 can be represented as 7/1). Some (but not all) floating pointer numbers (i.e., real numbers) are rational numbers as well. The floating point number 2.5 is also a rational number, because it can be represented as the fraction 5/2. Create a class RationalNumber(fractions) with these capabilities Implement a constructor that receives two integer parameters (the first is the numerator, and the second is the denominator) that prevents a 0 denominator in a fraction, reduces or simplifies fractions that are not in reduced form and avoids negative denominators. a. b. Implement a printRational member function that prints out a RationalNumber object. c. Overload the addition +), subtraction (-), multiplication(), division (operators, and assignment () operators for this class. d. Overload the relational and equality (, 1/3 according to the overloaded operator -1/3 according to the overloaded 1/3 according to the overloaded operator |-1/3 according to the overloaded-operator !- 1/3 according to the overloaded-operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

Students also viewed these Databases questions

Question

Define marketing.

Answered: 1 week ago

Question

What are the traditional marketing concepts? Explain.

Answered: 1 week ago

Question

Define Conventional Marketing.

Answered: 1 week ago

Question

Define Synchro Marketing.

Answered: 1 week ago