Question: This must be done in C++ General Description: A rational number is of the form a/b , where a and b are integers, and b

This must be done in C++

General Description: A rational number is of the form a/b, where a and b are integers, and b is not equal 0. Develop and test a class for processing rational numbers.

Details:

  1. Your program should have 3 files: a driver file to test the operations, a header file for the class definition and any operator overloads you need, and an implementation file with the definitions of the items in the header file.

  1. The class should read and display all rational numbers in the form a/b,
    1. except when b is 1, then it should just display a
    2. or when b is 0, then it should display #div0

  1. The operations that should be implemented for the rational numbers are

Operator

Example

Result

Addition

3/8 + 1/6

13/24

Subtraction

3/8 1/6

5/24

Multiplication

3/8 * 1/6

1/16

Division

3/8 / 1/6

9/4

Invert

3/8 I

8/3

Mixed fraction

8/3 M

2 and 2/3

Reduce

6/8 R

3/4

Less than

1/6 < 3/8

True

Less than or equal to

1/6 <= 3/8

True

Greater Than

1/6 > 3/8

False

Greater than or equal

1/6 >= 3/8

False

Equal to

3/8 == 9/24

True

  1. The arithmetic operators must be overloaded to work with the class
  2. The class must have
    1. At least 2 private member variables, numerator and denominator
    2. At least 4 public member functions
      1. getNum(), getDen(), setNum(value), setDen(value)
  3. You must have internal documentation:

See the handout on Documentation Standards

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!