Question
C++ Program Matrix Arithmetic URGENT NEED ANSWER TODAY HELP ME FIX MY PROGRAM TO FOLLOW THE INSTRUCTIONS BELOW Program: Allows the user to add, subtract
C++ Program Matrix Arithmetic
URGENT NEED ANSWER TODAY
HELP ME FIX MY PROGRAM TO FOLLOW THE INSTRUCTIONS BELOW
Program: Allows the user to add, subtract and multiply of floating point matrices. It will be read from text files. Results will be written to text files. Put comments of the code.
The program allows the user to specify two matrices, A and B from files. Both matrices are initialized as 1x1 matrices containing 0s at the start.
Each row of the matrix is encoded in a separate line. The number of floating point numbers that could be extracted in sequence from the first line of the file determines the number of columns of the matrix. The numbers in a row are separated from each other by one or more white spaces. The row ends if either the end of the line has been reached or the next item on the line cannot be interpreted as a valid floating point number.
The number of rows of the matrix is determined from the number of lines, following the first line of the file, from which it is possible to extract the required number of floating point numbers (equal to the number of columns determined from the first line of the file).
The application implements a program loop, where each iteration of the loop consists of the following actions, in sequence:
* the properties of A and B are displayed
* the options available are displayed
* the user is prompted for a choice
* if the choice is valid, it is implemented
* feedback regarding the outcome of implementing the choice is displayed
Never clear the screen. Previous interactions between the application and the user must remain visible, except that the screen should be cleared if there is an option to clear the screen and the users avails of that option.
It is sufficient to display the dimensions of A and B when displaying their properties.
There must be options that allow the user to do the following:
* have new values for A imported from a file
* have new values for B imported from a file
* compute A+B
* compute A-B
* compute AB
* compute BA
* export the latest valid computation to a matrix file specified by the user
* terminate the application
Display only options that are valid. Do not display options for addition and subtraction if the two matrices cannot be added. Do not display options for computing a product if the product is not defined. Matrix files produced by the application should encode valid matrices that could be imported into either A or B.
A matrix retains its previous value if a request is made to replace it with a value that turns out to be invalid. For instance, the first line of a file might not contain anything that could be interpreted as being the first row of a matrix.
FEATURES THAT IS STRICTLY REQUIRED: **Write modular code.
**The program should have command line mode and interactive mode
**The program should never stop, goes into an infinite loop, crashes, nor hangs on any input, whether valid or invalid, except that the user may stop the application intentionally.
**The program will ask for two files (A and B) and will show the result (there should be another file made for result)
************************************************************
************************************************************
SOURCE CODE TEMPLATE (STRICTLY REQUIRED TO USE)
#include
using namespace std;
vector
vector
vector
int choices(vector
int choicesNotEqual(vector
void printerA(ifstream& fileA, vector
void printerB(ifstream& fileB, vector
int main(int argc, char ** argv) { vector
ifstream fileA(A);
if(!fileA.is_open()) { cout << "Cannot open File A" << endl; } else { printerA(fileA, matrA, tempstr, tempint, rowsA, colsA); }
fileA.close(); //End of File A
//File B string B=argv[2]; vector
if(!fileB.is_open()) { cout << "Cannot open File B" << endl; } else { printerB(fileB, matrB, tempstrB, tempintB, rowsB, colsB); }
fileB.close(); //End of File B
while(choice!='h') { //loop the function "choice" here // 'h' for exit }
return 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