Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Please give one *.h file and two *.cpp files. Problem Definition (Exercise 9.6 of the Deitel book) Create a class called Rational for performing

C++

Please give one *.h file and two *.cpp files.

image text in transcribed

image text in transcribed

Problem Definition (Exercise 9.6 of the Deitel book) Create a class called Rational for performing arithmetic with fractions. Use integer variables to represent the private data of the class the numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it is declared. The constructor should contain default values in case no initializers are provided. Provide public member functions that perform each of the following tasks . Adding two rational numbers .Subtracting two rational numbers. . Multiplying two rational numbers. . Print Rational numbers in the form a/b, where a is the numerator and b is the denominator The implementation of the class rational is divided in two steps Part 1: Class Definition Implement the class definition for class Rational in a file called Rational.h. The class definition should contain only the prototypes of the member functions Rational, setNumerator, setDenominator, add subtract, multiply and print. You also need to include the integer data members numerator and denominator Determine if the functions and the data members should be private or public. You can find an example of the class definition for the class Time in the file Time.h also available in Chapter 9.2 (page 379 of the Deitel book, ninth edition) Part 2.1: Member-function definition Implement the member-function definition of class Rational in a file called Rational cpp. This.cpp file contains the actual implementation of the member functions of class Rational You can find an example of the member-function implementation in the file Time.cpp also available in Chapter 9.2 (page 380 of the Deitel book) Part 2.2: Test program Write a program that tests your class Rational. Call your file This program should 1. Instantiate two objects of class Rational

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

Real Time Database Systems Architecture And Techniques

Authors: Kam-Yiu Lam ,Tei-Wei Kuo

1st Edition

1475784023, 978-1475784022

More Books

Students also viewed these Databases questions