architecture available to create those operations and data types. Assignment Description This assignment is an exercise in creating a complete class definition. A standard way to do that is to use a math data type. Here we define a Rational Number data type in a class called “Rational”. The distinctive feature of this type is the data is kept as numerator and denominator throughout all operations; there is no floating point representation used. The standard math operations, addition, subtraction, etc., are implemented, including the iostream overload. The student will not only come to understand what is required for a complete representation of such a type, but also learn about the internal mechanics of its C++ implementation. The student will be given the Rational.h header file. The student will complete the class definition by creating the Rational.cpp file. Program Requirements 1. The student will create

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Introduction The Object Oriented software model is designed to create a new data type by using the Class structure. Therefore the various operations which define a data type, such as the common operators, assignment, etc., have a software architecture available to create those operations and data types. Assignment Description This assignment is an exercise in creating a complete class definition. A standard way to do that is to use a math data type. Here we define a Rational Number data type in a class called “Rational”. The distinctive feature of this type is the data is kept as numerator and denominator throughout all operations; there is no floating point representation used. The standard math operations, addition, subtraction, etc., are implemented, including the iostream overload. The student will not only come to understand what is required for a complete representation of such a type, but also learn about the internal mechanics of its C++ implementation. The student will be given the Rational.h header file. The student will complete the class definition by creating the Rational.cpp file. Program Requirements 1. The student will create the Rational.cpp implementation for a class called Rational. The interface for the Rational class will be provided with all applicable method declarations. 2. The student will create the implementation for all methods defined in the header by creating the file named Rational.cpp. There may be additional helper methods defined as needed by the implementation. 3. The student will create a test driver to test each of the methods defined in the class. The test driver file will be called TestRational.cpp. 4. The student will submit the source file for the test driver, TestRational.cpp, and the Rational.cpp file. 5. The student will “zip” only the source files for submission. The name of the zip file will be “program1_studentlastname.zip”.

#ifndef RATIONAL_NUMBER_H_ #define RATIONAL_NUMBER_H_ #include class Rational { public: Rational(); Rational(int n,int d); Rational(const Rational&); // copy constructor ~Rational() {} void Set(int n,int d); void Get(int& n,int& d) const; bool isValid() const; void Set(const char*); Rational& operator= (const Rational &); // assignment operator bool operator== (const Rational &) const; bool operator!= (const Rational &) const; bool operator> (const Rational &) const; bool operator< (const Rational &) const; bool operator>= (const Rational &) const; bool operator<= (const Rational &) const; Rational& operator+= (int); Rational& operator-= (int); Rational operator+ (int) const; Rational operator- (int) const; Rational operator++ (int); Rational& operator++ (); Rational operator-- (int); Rational& operator-- (); Rational& operator+= (const Rational&); Rational& operator-= (const Rational&); Rational operator+ (const Rational&) const; Rational operator- (const Rational&) const; friend Rational operator+ (int,const Rational&); friend Rational operator- (int,const Rational&); friend std::ostream& operator<< (std::ostream&,const Rational &); const char* toString() const; operator const char*() { return toString(); } private: int n,d; // numerator, denominator }; #endif

i need full correct c++ code

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education