I am working in c++. My program requires me to use a header file that is provided. I must use this header file and create 5 methods: 2 constructors, 2 accessors and this operation* on a 4x4 matrix. Matrix has 16 floating point values that must be entered by user. The Two operator functions: i*t; and t+i, multiply identity (i) matrix by user input value matrix and second function add identity (i) plus user input matrix transform. These two operations must be able to be carried out on the same 4x4 matrix entered by the user. Here is header file below. The point of the work is to create an implementation of this class to be able to display in a console.
// Transform.h
//
#pragma once
#ifndef __Lecture_5__Transform__
#define __Lecture_5__Transform__
class Transform
{
public:
Transform(); // Identity Matrix
Transform(float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33); // Explicit ctor
// Accessors
float get(unsigned int row, unsigned int col) const;
void set(unsigned int row, unsigned int col, float value);
// Operations
Transform operator*(const Transform& rhs) const;
private:
float data[4][4];
};
#endif /* defined(__Lecture_5__Transform__) */
#include "Transform.h"
#include <iostream>
using namespace std;
// Identity Matrix
Transform::Transform(){
for(int i=0;i<4;i++){
for(int j =0;j<4;j++){
data[i][j]=1;
}
}
};
// Explicit constructor
Transform::Transform(float m00, float m01, float m02, float
m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33){
data[0][0]=m00;
data[0][1]=m01;
data[0][2]=m02;
data[0][3]=m03;
data[1][0]=m10;
data[1][1]=m11;
data[1][2]=m12;
data[1][3]=m13;
data[2][0]=m20;
data[2][1]=m21;
data[2][2]=m22;
data[2][3]=m23;
data[3][0]=m30;
data[3][1]=m31;
data[3][2]=m32;
data[3][3]=m33;
};
// Accessors
float Transform::get(unsigned int row, unsigned int col){
return data[row][col];
}
// Mutator
void Transform::set(unsigned int row, unsigned int col, float
value){
data[row][col] = value;
}
// Operator overloading
Transform Transform::operator*(Transform& rhs){
Transform t;
for(int i=0;i<4;i++){
for(int j =0;j<4;j++){
cout<<data[i][j]*rhs.get(i,j);
t.set(i,j,data[i][j]*rhs.get(i,j));
}
}
}
Transform Transform::operator+(Transform& rhs){
Transform t;
for(int i=0;i<4;i++){
for(int j =0;j<4;j++){
t.set(i,j,data[i][j]+rhs.get(i,j));
}
}
}
main.cpp:
#include <iostream>
#include "Transform.h"
#include <iomanip>
using namespace std;
int main()
{
Transform t1,t2;
float value;
cout << "Identity matrix:" << endl;
for(int i=0;i<4;i++){
for(int j =0;j<4;j++){
cout<<t1.get(i,j)<<" ";
}
cout<<endl;
}
cout<<"Enter matrix data: "<<endl;
for(int i=0;i<4;i++){
for(int j =0;j<4;j++){
cout<<"Enter floating
number"<<i<<","<<j<<": ";
cin>>value;
t2.set(i,j,value);
}
}
Transform t3 = t2*t1;
cout << "Multipled matrix:" << endl;
for(int i=0;i<4;i++){
for(int j =0;j<4;j++){
cout<<t3.get(i,j)<<" ";
}
cout<<endl;
}
Transform t4 = t2+t1;
cout << "Addition matrix:" << endl;
for(int i=0;i<4;i++){
for(int j =0;j<4;j++){
cout<<t4.get(i,j)<<" ";
}
cout<<endl;
}
return 0;
}
I am working in c++. My program requires me to use a header file that is...
I only need the "functions" NOT the header file nor the main
implementation file JUST the implementations for the
functions
Please help, if its difficult to do the complete program I would
appreciate if you could do as much functions as you can especially
for the derived class.
I am a beginer so I am only using classes and pointers while
implementing everything using simple c++ commands
thank you in advanced
Design and implement two C++ classes to provide matrix...
I need help modifying this program. How would I make sure that the methods is being called and checked in my main method? Here is what the program needs to run as: GDVEGTA GVCEKST The LCS has length 4 The LCS is GVET This is the error that I'm getting: The LCS has length 4 // I got this right The LCS is //the backtrace is not being called for some reason c++ code: the cpp class: /** * calculate...
I need help with the code below. It is a C program, NOT C++. It can only include '.h' libraries. I believe the program is in C++, but it must be a C program. Please help. // // main.c // float_stack_class_c_9_29 // // /* Given the API for a (fixed size), floating point stack class, write the code to create a stack class (in C). */ #include #include #include #include header file to read and print the output on console...
So I have a question in regards to my program. I'm learning to program in C and I was curious about the use of functions. We don't get into them in this class but I wanted to see how they work. Here is my program and I would like to create a function for each of my menu options. I created a function to display and read the menu and the option that is entered, but I would like to...
C++ must use header files and implementation files as separate files. I’ll need a header file, implementation file and the main program file at a minimum. Compress these files into one compressed file. Make sure you have adequate documentation. We like to manipulate some matrix operations. Design and implement a class named matrixMagic that can store a matrix of any size. 1. Overload the addition, subtraction, and multiplication operations. 2. Overload the extraction (>>) and insertion (<<) operators to read...
Please help!! I am supposed to write a program in C++ about student & grades. Needs to have two functions that sorts students letter grade, and another one to sort Students name in your student’s record project. Remember, to add necessary parameters and declaration in main to call each function properly. Order of functions call are as follow Read Data Find Total Find average Find letter grade Call display function Call sort letter grade function Call display function Call sort...
This program is in C++ which reserves flight seats. It uses a file imported to get the seat chart called "chartIn.txt" which looks like this 1 A B C D E F 2 A B C D E F It continues until row 10. Sorry unable to provide the chartIn.txt file. I am having issues with function displaySeats, it displays then but when it comes to 10 the row looks like this 1 0 A B C D E ,...
C++ Assignment - Only Implementation file( VectorDouble.cpp file) required. The header file is already given. Please help, thumbs up guaranteed. Chapter 8 discussed vectors, which are like arrays that can grow in size. Suppose that vectors were not defined in C++. Define a class called VectorDoublethat is like a class for a vector with base type double. Your class VectorDoublewill have a private member variable for a dynamic array of doubles. It will also have two member variables of type...
Write a program in C++ that simulates a soft drink machine. The program will need several classes: DrinkItem, DrinkMachine and Receipt. For each of the classes you must create the constructors and member functions required below. You can, optionally, add additional private member functions that can be used for doing implementation work within the class. DrinkItem class The DrinkItem class will contains the following private data members: name: Drink name (type of drink – read in from a file). Type...
I am having trouble figuring out why my program will not make any columns, just rows. I need to display a square. The instructions are provided below. (This for my C++ class) Write a program that displays a square. Ask the user for the square’s size. Only accept positive integer numbers (meaning choose a data type that holds positive integer values). The size the user gives you will determine the length and width of the square. The program should then...