Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 Set Size (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 Mult Compatible (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 line 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 C:\Users\Erickson\Documents\Visual Studio 2015\Projects\MatrixTy... - Choice and parameters: 0 New Matrix Usage: 0 1 Add Matrices Usage: 1 5 Quit Usage: 5 Enter Choice and Parameters: 0 Creating new matrix in slot 0. Enter row and column size: 3 3 Row 0: 1 2 3 Row 1: 4 5 6 Row 2: 7 8 9 [ 1 2 3 ] [ 4 5 6 ] [ 7 8 9 ] Choice and parameters: 10 New Matrix Usage: 0 1 Add Matrices Usage: 1 2 Subtract Matrices Usage: 2 3. Multiply Matrices Usage: 3 4 Print Matrices Usage: 4 5 Quit Usage: 5 Enter Choice and Parameters: Some potentially useful strategies. The following code allows the user to enter a row of data separated by whitespaces and places it into an array: cout > item; arr[i] = item; Deliverables Your MatrixType class Your test driver Your test plan as input to the test driver (See page 125 for an example) The output file from the test driver A copy of the screen from the run of the test driver Extra Credit Opportunities The following are extensions that can be done for extra credit. They are additive (i.e. you can do both). Additional Matrix Operations (1-2%) Additional extra credit is available for those who implement additional matrix operations. The amount of extra credit will depend on how many operations are implemented and tests to demonstrate functionality. Overloading Operators (3-5% extra) This concept has not been covered yet but is covered in Chapter 6. If you are feeling ambitious, you can read about how operators are overloaded implement the operators for addition, subtraction and multiplication

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 Systems On GPUs In Databases

Authors: Johns Paul ,Shengliang Lu ,Bingsheng He

1st Edition

1680838482, 978-1680838480

More Books

Students also viewed these Databases questions