Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ A rational number is of the form a/b , where a and b are integers, and b is not equal 0. Develop and test

C++ 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.Pointers aren't needed and it should be able to handle all of these examples and more. Its supposed to accept a rational number dynamically in the form of "a/b" and tell you the result.

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,
  2. The operations that should be implemented for the rational numbers are
  3. except when b is 1, then it should just display a
  4. or when b is 0, then it should display #div0

  5. Operator

    Example

    Result

    Addition

    3/9 + 1/7

    10/21

    Subtraction

    3/9*1/7

    4/21

    Multiplication

    3/8 * 1/6

    1/16

    Division

    3/8 / 1/6

    9/4

    Invert

    2/4 I

    4/2

    Mixed fraction

    8/3 M

    2 and 2/3

    Reduce

    18/24 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

  6. The arithmetic operators must be overloaded to work with the class
  7. The class must have
    1. At least 2 private member variables, numerator and denominator
    2. At least 4 public member functions
      1. getNu(), getDe(), setNu(value), setDe(value)

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

What are some of the possible scenes from our future?

Answered: 1 week ago