Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please code in C++: Assignment 1: MatrixType Many mathematical problems require the addition, subtraction, and multiplication of two matrices. Write an ADT Matrix. You may

Please code in C++:

image text in transcribedimage text in transcribedimage text in transcribed

Assignment 1: MatrixType Many mathematical problems require the addition, subtraction, and multiplication of two matrices. Write an ADT Matrix. You may use the following class definition. const int MAX_ROWS = 10; const int MAX_COLS = 10; class MatrixType public: MatrixType(); void MakeEmpty(); void SetSize (int rows Size, int colSize); void StoreItem(int item, int row, int col); void Add (MatrixType otheroperand, MatrixType & result); void Sub (MatrixType otherOperand, MatrixType & result); void Mult (MatrixType otheroperand, MatrixType& result); void Print (ofstream& outfile); bool AddSubCompatible (MatrixType otherOperand); bool MultCompatible (MatrixType otherOperand); private: int values [MAX_ROWS] [MAX_COLS]; int numRows; int numCols; ); Before you start looking at how to implement this class, you must determine and document the appropriate preconditions and postconditions for each operation. Note that the class provides the member functions to allow the client to determine if the binary matrix operations are possible. Before this class can become a permanent part of your program library, it must be thoroughly tested. Write a menu driven testing program to test your MatrixType. Menu Driven Testing Interface The menu should contain the following options. (See processing notes for definition of ). O New Matrix Ask for width. Ask for height. Based on width and height, ask for the value of each position. This can be done one at a time, or row by row. Your choice. 1 Add Matrices Add first and second, leaving the result in the third 2 Subtract Matrices Subtract second from first, leaving the result in the third 3 Multiply Matrices Multiply first and second, leaving the result in the third 4 Print Matrix Print the matrix one row per linc on DataOut 5 Quit Processing Notes 1. is a number between 0 and 9. This value is used as an index into an array of MatrixType. 2. The main function must include a Switch statement where the case expression is a user-defined enumeration type. This means that the command is recognized and its enumeration equivalent is sent back to be used in the case statement. 3. The driver must ensure the preconditions of the member functions of MatrixType. Report any errors that occur and continue processing. Sample Run The following is a sample of possible way to create a menu and accept matrix input. O X HC:\Users\Erickson\Documents\Visual Studio 2015 Projects\MatrixTy... - Choice and parameters: New Matrix Usage: 0 3 Multiply Matrices Usage: 3 4 Print Matrices Usage: 4 5 Quit Usage: 5 Enter Choice and Parameters: 0 0 Creating new matrix in slot 0. Enter row and column size: 33 Row 0: 1 2 3 Row 1: 4 5 6 Row 2: 7 8 9 [ 1 2 3] [ 4.56] [ 7 8 9 ] Choice and parameters: New Matrix Usage: 0 4 Print Matrices Usage: 4 > item; arr[i] = item; Deliverables Your MatrixType class Your test plan as input to the test driver The output file from your test plan inputs A copy of the screen from the run of the test plan

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124251, 978-3031124259

More Books

Students also viewed these Databases questions