Answered step by step
Verified Expert Solution
Question
1 Approved Answer
General Instructions: Given a matrix of size MxN, the objective of the program is to flip the matrix horizontally along the center. The input file
General Instructions: Given a matrix of size MxN, the objective of the program is to flip the matrix horizontally along the center. The input file provides the size of the matrix to be generated. Once created, it should be filled with random numbers. When the matrix is not a square matrix, pad the matrix with zeroes to get a square matrix before transforming. Specific Instructions: This assignment should be written as a modular C++ program. You will develop a class (module) called Horizontal_Flip, with header (.h) and implementation (.cpp) files. The main program should be in its own module, and it is given to you. In this program, an input file (input.txt) is provided with size of the matrices. You need to generate the matrix and populate it with random numbers. The function rand can be used to generate the matrix. If the generated matrix is not a square matrix, pad the matrix with zeroes at the bottom and/or on the right to make it a square matrix. Now, flip the matrix horizontally along the center and print the final output to the screen and in a file (output.txt). For each change in matrix size, add a counter to track the number of times the matrix is re-sized. Please see the given input and output files for examples. Note: Size of the matrix should be greater than 33 and middle row/column for the odd sized matrices stays the same. Programming concepts that are expected in the solution: 1. Object oriented modular solution 2. File 10 3. Use of operator overloading 4. All DMM requirements Driver Code: Hinclude using namespace std; Hinclude "Horizontal_Flip.h" int main() f Horizontal_Flip key; std:lifstream file_in("input.txt"); std:tofstream file_out("output.txt"); if (file_in.is_open() \&\& file_out.is_open()) while (Ifile_in.eof()K file_in s>ey; key.Flip(); cout key; file_out key; \} return 0; Input file: Output file: Generated Matrix: 241314454 // You are encouraged to add // more lines of input. Number of times matrix is re-sized: 0
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