Question
WILL UPVOTE IF DONE CORRECTLY! (OUTPUT MUST MATCH ONE SHOWN BELOW!!) ----------------------------------------------------------------------------------------------------- THIS IS NOT THE CORRECT ANSWER DO NOT RESPOND WITH THIS C++ CODE:
(OUTPUT MUST MATCH ONE SHOWN BELOW!!)
-----------------------------------------------------------------------------------------------------
THIS IS NOT THE CORRECT ANSWER DO NOT RESPOND WITH THIS
C++ CODE:
#include
using namespace std;
// Class named \" calculator\".
class calculator
{ // Private data members.
int a,b;
public:
// Constructor for initializing a and b values.
calculator(int x,int y)
{
a=x;
b=y;
}
// add() function for finding sum.
void add()
{
int sum;
sum=a+b;
cout\">
}
// subtract() function for finding sub.
void subtract()
{
int sub;
sub=a-b;
cout\">
}
// Multiply() function for finding product.
void multiply()
{
int mul;
mul=a*b;
cout\">
}
// Division() function for finding div.
void division()
{
float div;
div=float(a)/float(b);
cout\">
}
// Remainder() function for finding remainder
void remainder()
{
int rem;
rem=a%b;
cout\">
}
// Percentage() for finding the percentage of a in total of b.
void percentage()
{
float per;
per= (float(a)/float(b))*100;
cout\">
}
};
// Main function
int main()
{
int x,y;
// Taking input.
cout\">
cin>>x>>y;
// Creating class object.
calculator obj(x,y);
// Calling the calculator class functions using object obj.
obj.add();
obj.subtract();
obj.multiply();
obj.division();
obj.remainder();
obj.percentage();
}
-------------------------------------------------------------------------------
write a main.cpp and matrix.cpp that compile with the header file that creates a class that stores and manipulates matrices and develop operator overloads.
Sample Output:
Enter 4 numbers for Row1:1
1
1
1
Enter 4 numbers for Row2:2
2
2
2
Enter 4 numbers for Row3:3
3
3
3
Enter 4 numbers for Row4:4
4
4
4
Enter 4 numbers for Row1:1
1
1
1
Enter 4 numbers for Row2:2
2
2
2
Enter 4 numbers for Row3:3
3
3
3
Enter 4 numbers for Row4:4
4
4
4
Matrix Output Matrix1 after input
Row size = 4 Column Size = 4
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
Matrix Output Matrix2 after input
Row size = 4 Column Size = 4
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
Enter 3 numbers for Row1:1
2
3
Enter 3 numbers for Row2:4
5
6
Enter 3 numbers for Row1:7
8
9
Enter 3 numbers for Row2:10
11
12
Enter 3 numbers for Row3:13
14
15
Multiplying matrix of size 2x3
Matrix Output Duplicate Multiplication
Row size = 2 Column Size = 3
66 72 78
156 171 186
header file:
#ifndef MATH_H
#define MATH_H
#include
using namespace std;
class Matrix_Class {
public:
Matrix_Class(); // Default Constructor
Matrix_Class(const int r, const int c=6); // Constructor
~Matrix_Class(); // Destructor
void Clear(); // Delete Matrix
void Zero(); // Set all values to zero
void Print( string msg)const; // Print Matrix to Stdout
void Input(); // Input Matrix from Stdin
void Resize(const int r, const int c); // Clear and resize to row and col
int Getrowsize() { return rowsize; } // Inline function to return rowsize
int Getcolsize() { return colsize; } // Inline function to return colsize
Matrix_Class & operator = (const Matrix_Class & m);
Matrix_Class & operator * (Matrix_Class & m1);
private:
int * * matrix; // 2d array that holds the matrix
int rowsize;
int colsize;
};
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