Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Program Matrix Arithmetic Please follow all instruction given C++ program: Allows the user to add, subtract and multiply of floating point matrices. It will

C++ Program Matrix Arithmetic

image text in transcribed

image text in transcribed

image text in transcribed

Please follow all instruction given

C++ 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 O's at the start. Matrix data for a matrix with mrows and n columns are encoded in a text file as follows: a1,1 a1,2... a1, n optional comments a2. 1 a 2,2... a2, n optional comments am. 1 am, 2 ... am, n optional comments optional comments 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) |

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions