Question
C++ Develop a rational number calculator. It should accept all examples below and any rational number the user puts in it. A rational number is
C++ Develop a rational number calculator. It should accept all examples below and any rational number the user puts in it. A rational number is of the form a/b, where a and b are integers with b 0. Develop and test a class for processing rational numbers. The class should have a numerator data member and a denominator data member. It should read and display all rational numbers in the format a/b; for output, just display a if the denominator is 1. The following examples illustrate the operations that should be provided.
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.
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 |
- At least 2 private member variables, numerator and denominator
- You need at least 4 public member functions
- getNu(), getDe(), setNu(value), setDe(value)
- Please use internal Documentation
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started