In c++
Write a class called Fraction that allows you to work with fraction arithmetic. Use integer variables to represent the private data of the class: the numerator and the denominator. Write a constructor that allows an object of this class to be initialized when it is declared. The constructor must contain default values in case there are no initializers (0/1), and must store the fraction in reduced form. For example, the fraction 2 / 4 would be stored in the object as 1 in the numerator and 2 in the denominator. When creating the fraction, avoid (negative numerator and denominator), (positive numerator and negative denominator). Fractions should ALWAYS be stored in a simplified way Write public member functions to perform each of the following tasks: - Addition of two Fractions. The result should be stored in reduced form. Multiplication of two Fractions. The result should be stored in reduced form. Print Fractions in the forma /b, where a is the numerator and b is the denominator. Also write a class called MatFrac that allows to represent arrays of Fractions Write a program that allows you to add two Fraction Matrices using the classes mentioned above. The execution of the program must receive the name of a text file (where the data of Matrix 1 is located), another name of a text file (where the data of Matrix2 is located) and as a result, it asks for a file name to generate a text file containing the data of the result matrix if the sum is feasible, or if the sum is not feasible, a message is displayed on the screen that says: "Operation impossible. The matrices must be of the same dimensions to be able to add them". In addition to that, in case the operation is feasible, it displays on the screen: Matrix 1 Matrix 2 Matrix 3
In c++
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am