Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the question is already answer but the method is different with same console : Here are the main points that I want you to learn

the question is already answer but the method is different with same console :

Here are the main points that I want you to learn in this assignment:

Designing classes.

Instantiating objects.

Using objects.

Copy/paste in the following code and compile it to verify that the IDE is working correctly. This is, in fact, the solution for assignment 11.

// Assignment11.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include

#include

using namespace std;

int main() {

int size, m, n, c, d, first[10][10], second[10][10], sum[10][10];

cout << "Enter the number of rows and columns of matrices: ";

cin >> size;

m = size; n = size;

cout << "Enter the elements of first matrix: ";

for ( c = 0 ; c < m ; c++ )

for ( d = 0 ; d < n ; d++ )

cin >> first[c][d];

cout << "Enter the elements of second matrix: ";

for ( c = 0 ; c < m ;c++ )

for ( d = 0 ; d < n ; d++ )

cin >> second[c][d];

for ( c = 0 ; c < m ; c++ )

for ( d = 0 ; d < n ; d++ )

sum[c][d] = first[c][d] + second[c][d];

cout << "Sum of entered matrices:- ";

for ( c = 0 ; c < m ; c++ ) {

for ( d = 0 ; d < n ; d++ )

cout << sum[c][d] << "\t";

cout << endl;

}

cout << "Hit any key to continue" << endl;

system ("pause");

return 0;

}

When you initially execute the code, just make sure it is working and free of errors. You should see the following output when you enter the identical inputs.

The Problem

In this assignment, I don't want you to change any functionality. The solution for assignment 11 was not very object-oriented. For this assignment, I want you to design a class to perform all of the operations that we did in assignment 11.

Thus, you will create a class called Matrix and then design the class to use the attributes from assignment 11 and then create methods to support them. Keep all of the code in a single .cpp file.

class Matrix {

};

You will have 2 methods:

initMatrix () {

}

printMatrix() {

}

You can create the object with the following code in the main:

Matrix M1;

In the main:

1. create the object

2. use initMatrix to initialize

3. use printMatrix to print

The output will look the same because the functionality remains the same. The design is what we updated.

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 Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions