Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A sample output could be as follows: Please enter data for 1st ratio: Enter numerator : 4 Enter denominator : 7 Please enter data for

image text in transcribedimage text in transcribed
A sample output could be as follows: Please enter data for 1st ratio: Enter numerator : 4 Enter denominator : 7 Please enter data for 2nd ratio: Enter numerator: 27 Enter denominator: 14 Ratio 1 is: 4/7 Ratio 2 is: 27/14 what would you like to do with these ratios? Menu: Press 1 for addition. Press 2 for subtraction Press 3 For multiplication Press 4 for division Press 5 for increment Press 6 for decrement Enter your option: 1 You have chosen addition. The result is: 4/7 + 27/14 = 245/98 = 5/2Create a ratio class that contains the following members: A private data member to store numerator A private data member to store denominator A default constructor that initializes the numerator and denominator to 1. - A constructor with two parameters to initialize the values of numerator and denominator. An overloaded + operator to add two ratio objects. An overloaded operator to subtract two ratio objects. An overloaded * operator to multiply two ratio objects. - An overloaded / operator to divide two ratio objects. An overloaded ++ operator to increment a ratio object. An overloaded operator to decrement a ratio object. An overloaded insertion operator (>) to get numerator and denominator of a ratio object from the user. Design the main( ) function that prompts the user to create two ratio objects. The program will ask the user to choose an operation that user wants to apply on ratio objects and then should print the result accordingly. Increment and decrement operations should be applied on only one object of user's choice (as these are unary operation). After every operation result, the program should ask user if user wants to apply another operation. Simplification of ratio after any operation through greatest common divisor is also required. Your program should also contain the code that will check for and handle errors. A sample output could be as follows

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions