Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please show it with C++. Thank you! Create a class called Rational for performing arithmetic with fractions. Use integer variables to represent the private data

image text in transcribed

image text in transcribed

Please show it with C++. Thank you!

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 Bational.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 Rationalcpp. 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 fle 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. tetBationalcoR. This program should 1. Instantiate two objects of c Rationa

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

OUTCOME 2 Outline the methods by which firms recruit internally.

Answered: 1 week ago