Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Could somebody please, how to write this c++ program? Here are the fractions.cpp Start with the program fractions.cpp Modify it to 1. Dynamically allocate two
Could somebody please, how to write this c++ program?
Here are the fractions.cpp
Start with the program fractions.cpp Modify it to 1. Dynamically allocate two arrays to hold Fration structs and initialize data in each array from files The Fractions are created for each array by reading data from two separate files The first value in each file is the size of the array Each data file contains a value indicating how many fractions are in the file, followed by the numerator and denominator for each. Elfractiondatalbt a fractiondata2tt E3 2 2 3 3 1 4 3 1 4 4 3 4 4 1 2 5 1 12 5 4 11 2 5 6 2 12 7 29 7 29 8 3 7 8 5 8 9 2 3 9 2 7 100 2 3 10 2 3 2. Construct a method that takes an array of Fractions and outputs the contents. Use the tostring method to print each fraction void printFractions(Fraction fractions) 3. Construct methods to add, subtract, multiply, and divide two Fractions and return a Fraction that represents the result. For example, here is a signature for an add method: Fraction add(Fraction &op1, Fraction &op2); (If you want to experiment with sending pointers to Fraction structs and dynamically allocating the result struct, you are welcome to do that 4. Loop through your Fraction arrays and output the result of applying each operation (add, subtract, multiply, and divide) to the Fractions at parallel positions in the arrays. Fraction result add (fractions1.fractions Oil, fractions2.fractions [i]) coutStep 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