Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program in C++ with the following requirements: 1- Create the class Fraction (this class will have two member variables of type int): a)
Write a program in C++ with the following requirements: 1- Create the class "Fraction" (this class will have two member variables of type int): a) The class must have 3 constructors: default, with parameters using initializer list, and the copy constructor. b) The class should overload the assignment (=) operator. c) The class should have "get" and "set" methods for the member variables. d) The class should have the functionalities: addition, subtraction, multiplication, and division. e) The class should have the method print() that prints the fraction. f) The class should have the method simplify() which will reduce the resulting fraction to the lowest terms. 1- Write the main function in a separate file where you will implement the logic of a calculator over "Fraction" objects only for the functionalities that are implemented in "Fraction" class. For example, you can create three objects from the class "Fraction" where the first object will hold the first fraction, the second object will hold the second fraction, and the third object will hold the result. The operations that will be used over the objects, need to be chosen by the user (ex: user will enter A for Addition and D for Division and so on...). It is recommended to use the "switch" statement to check the operation entered. The program will end when the user enters E (meaning exit). It is recommended to use "while" or "dowhile" loop to control the termination of the program
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