Homework Solution: To answer to a comment, the code is not already implemented. The code does not s…

    To answer to a comment, the code is not already implemented. The code does not solve 3x3 systems. It lacks the "ability" to do row reduced echelon calculations or Gauss Jordan elimination (it's the same thing, here's a link that explains it http://pages.pacificcoast.net/~cazelais/251/gauss-jordan.pdf) The code that I posted simply provides the basis. You have to write a class that inherits from my class, so it gets the Matrix information that the user puts in, afterward the new class that you write will implement the Gaus Jordan calculation. I hope this clears up the confusion [C++]I need to write a class that solves 3x3 systems of equations (3 equations with 3 unknowns). (This is about Matrices reduced to row echelon form). If you do don't know how to do this, please, don't answer this question! If anything is unclear just comment, and I will try to clear up the confusion. Additionally, the class should be derived from and has a base of the class of HW.1 (So the class that is going to be written inherits from the class that I wrote in my first home work) This is important so that it has access to the Matrix information. Here's the link to my code: Essentially, it just needs to get expanded with another class that inherits from the first one to do the row echelon calculation. https://repl.it/KhHC/12 #include using namespace std; class Matrix{ private : double A[3][3]; double B[3][3]; double result[3][3]; public : /*------------------------------------------------------- FUNCTON NAME: input PARAMETERS: RETURN TYPE: DESCRIPTION: Stores user values inside the corresponding arrays to be referenced later -------------------------------------------------------*/ void input(){ cout << "Input 9 elements into your 3x3 matrix A: "; for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { cin >> A[i][j]; // terminates function on failure if(cin.fail()) { cin.clear(); cin.ignore(100, 'n'); cerr << "nERROR: Please enter valid input!n" << endl; } } } cout << "Input 9 elements into your 3x3 matrix B: "; for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { cin >> B[i][j]; // terminates function on failure if(cin.fail()) { cin.clear(); cin.ignore(100, 'n'); cerr << "nERROR: Please enter valid input!n" << endl; } } } } /*------------------------------------------------------- FUNCTON NAME: print PARAMETERS: result RETURN TYPE: will output the results of the array calculation DESCRIPTION: This function will print out the results from the subtraction and addition function -------------------------------------------------------*/ void print(double result[3][3]){ for(int i = 0; i < 3; i++) { cout << "["; for(int j = 0; j < 3; j++) { cout << result[i][j] << "t"; } cout << "]" << endl; } } /*------------------------------------------------------- FUNCTON NAME: printAB PARAMETERS: RETURN TYPE: DESCRIPTION: This function will simply display the Matrices of A and B right after the user has finished their input -------------------------------------------------------*/ void printAB(){ cout<<"nMatrix A :"< for(int i = 0; i < 3; i++) { cout << "["; for(int j = 0; j < 3; j++) { cout << A[i][j] << "t"; } cout << "]" << endl; } cout<<"nMatrix B :"< for(int i = 0; i < 3; i++) { cout << "["; for(int j = 0; j < 3; j++) { cout << A[i][j] << "t"; } cout << "]" << endl; } } /*------------------------------------------------------- FUNCTON NAME: addition PARAMETERS: RETURN TYPE: DESCRIPTION: This function will perform the addition and the print function will output the result -------------------------------------------------------*/ void addition(){ for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { result[i][j] = A[i][j] + B[i][j]; } } print(result); } /*------------------------------------------------------- FUNCTON NAME: subtraction PARAMETERS: RETURN TYPE: DESCRIPTION: This function will perform the subtraction and the print function will output the result -------------------------------------------------------*/ void subtraction(){ for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { result[i][j] = A[i][j] - B[i][j]; } } print(result); } /*------------------------------------------------------- FUNCTON NAME: determinant PARAMETERS: RETURN TYPE: determin, an integer DESCRIPTION: This function will find the determinant -------------------------------------------------------*/ int determinant(){ int determin = 0; //finding the determinant for(int i = 0; i < 3; i++) determin = determin + (A[0][i] * (A[1][(i+1)%3] * A[2][(i+2)%3] - A[1][(i+2)%3] * A[2][(i+1)%3])); return determin; } /*------------------------------------------------------- FUNCTON NAME: inverse PARAMETERS: RETURN TYPE: DESCRIPTION: This function will find the inverse and output the result -------------------------------------------------------*/ void inverse(){ cout <<"nnInverse of Matrix A is: n"; cout << " " << endl; for(int i = 0; i < 3; i++){ for(int j = 0; j < 3; j++) cout<< "[" << ((A[(j+1)%3][(i+1)%3] * A[(j+2)%3][(i+2)%3]) - (A[(j+1)%3][(i+2)%3] * A[(j+2)%3][(i+1)%3]))/ determinant()<< "]" << "t"; cout<<"n"; } } }; //Main function int main() { //Initializing Variables; "choice" will initiate a a loop, "input" will come in useful to do a switch statement, and obj will simply create another instance of the original class that can be manipulated bool choice; char input; Matrix obj; cout << "nWhen filling up matrices, separate individual elements by a space (e.g 2 4 1.4 56.3 ...) nn"; obj.input(); obj.printAB(); //Displaying a menu, so that the user can choose what he wants to do choice = false; //The Loop while(!choice) { cout << " " << endl; cout <<"** Choose from the following **"<< endl; cout << " " << endl; cout << "a - Addition" << endl; cout << "s - Subtraction" << endl; cout << "d - Determinant" << endl; cout << "i - Inverse" << endl; cout << "q - Quit" << endl; cout << " " << endl; cout << "Note: Choosing 'i' or 'd' will only apply to Matrix A" << endl; cout << " " << endl; cout << "Enter your choice: "; cin >> input; cout << endl; //A switch to handle the user inputs switch(input){ case 'a': case 'A': obj.addition(); break; case 's': case 'S': obj.subtraction(); break; case 'd'|'D': cout<<"Determinant is : "< cout << " " << endl; break; case 'i': case 'I': obj.inverse(); break; case 'q': case 'Q': exit(0); default:cout<<"nERROR: Please enter valid input!nn"; } } return 0; }

    Expert Answer

    #include using namespace std; class Matrix{

    To exculpation to a interpret, the principle is not already utensiled. The principle does not attributable attributable attributable manifest-up 3×3 systems. It lacks the “ability” to do order dejected echelon anticipations or Gauss Jordan end (it’s the similar subject, here’s a be-mixed that explains it http://pages.pacificcoast.net/~cazelais/251/gauss-jordan.pdf)

    The principle that I posted barely provides the cause. You bear to transcribe a tabulate that inherits from my tabulate, so it obtains the Matrix instruction that the user puts in, forthcomingcitedward the strange tabulate that you transcribe conciliate utensil the Gaus Jordan anticipation. I expectation this manifests up the indistinctness

    [C++]I demand to transcribe a tabulate that manifest-ups 3×3 systems of equations (3 equations with 3 unknowns). (This is encircling Matrices dejected to order echelon conceive).

    If you do don’t apprehend how to do this, fascinate, don’t exculpation this question! If anysubject is unmanifest fair interpret, and I conciliate aim to manifest up the indistinctness.

    Additionally, the tabulate should be extraneous from and has a cheap of the tabulate of HW.1 (So the tabulate that is going to be written inherits from the tabulate that I wrote in my pristine abode work)

    This is leading so that it has entrance to the Matrix instruction. Here’s the be-mixed to my principle:

    Essentially, it fair demands to obtain remote with another tabulate that inherits from the pristine idiosyncratic to do the order echelon anticipation.

    #include
    using nameextension std;

    tabulate Matrix{

    private :
    embrace A[3][3];
    embrace B[3][3];
    embrace development[3][3];

    public :
    /*——————————————————-
    FUNCTON NAME: input
    PARAMETERS:
    RETURN TYPE:
    DESCRIPTION: Stores user values within the similar marshals to be referenced later
    ——————————————————-*/
    void input(){

    cextinguished << “Input 9 elements into your 3×3 matrix A: “;

    for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
    cin >> A[i][j];
    // terminates capacity on missure
    if(cin.fail()) {
    cin.clear();
    cin.ignore(100, ‘n’);
    cerr << “nERROR: Fascinate invade strong input!n” << endl;
    }
    }
    }

    cextinguished << “Input 9 elements into your 3×3 matrix B: “;

    for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
    cin >> B[i][j];
    // terminates capacity on missure
    if(cin.fail()) {
    cin.clear();
    cin.ignore(100, ‘n’);
    cerr << “nERROR: Fascinate invade strong input!n” << endl;
    }
    }
    }
    }
    /*——————————————————-
    FUNCTON NAME: imprint
    PARAMETERS: development
    RETURN TYPE: conciliate extinguishedput the developments of the marshal anticipation
    DESCRIPTION: This capacity conciliate imimsculpture extinguished the developments from the division and abstracted capacity
    ——————————————————-*/
    void imprint(embrace development[3][3]){
    for(int i = 0; i < 3; i++) {
    cextinguished << “[“;
    for(int j = 0; j < 3; j++) {
    cextinguished << development[i][j] << “t”;
    }
    cextinguished << “]” << endl;
    }
    }
    /*——————————————————-
    FUNCTON NAME: imprintAB
    PARAMETERS:
    RETURN TYPE:
    DESCRIPTION: This capacity conciliate barely vault the Matrices of A and B fair forthcomingcited the user has perfect their input
    ——————————————————-*/
    void imprintAB(){
    cout<<“nMatrix A :”< restraint(int i = 0; i < 3; i++) {
    cextinguished << “[“;
    for(int j = 0; j < 3; j++) {
    cextinguished << A[i][j] << “t”;
    }
    cextinguished << “]” << endl;
    }

    cout<<“nMatrix B :”< restraint(int i = 0; i < 3; i++) {
    cextinguished << “[“;
    for(int j = 0; j < 3; j++) {
    cextinguished << A[i][j] << “t”;
    }
    cextinguished << “]” << endl;
    }
    }
    /*——————————————————-
    FUNCTON NAME: abstracted
    PARAMETERS:
    RETURN TYPE:
    DESCRIPTION: This capacity conciliate perconceive the abstracted and the imimsculpture capacity conciliate extinguishedput the development
    ——————————————————-*/
    void abstracted(){
    for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
    result[i][j] = A[i][j] + B[i][j];
    }
    }
    print(result);
    }
    /*——————————————————-
    FUNCTON NAME: division
    PARAMETERS:
    RETURN TYPE:
    DESCRIPTION: This capacity conciliate perconceive the division and the imimsculpture capacity conciliate extinguishedput the development
    ——————————————————-*/
    void division(){
    for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
    result[i][j] = A[i][j] – B[i][j];
    }
    }
    print(result);
    }
    /*——————————————————-
    FUNCTON NAME: determinant
    PARAMETERS:
    RETURN TYPE: determin, an integer
    DESCRIPTION: This capacity conciliate meet the determinant
    ——————————————————-*/
    int determinant(){
    int determin = 0;
    //finding the determinant
    for(int i = 0; i < 3; i++)
    determin = determin + (A[0][i] * (A[1][(i+1)%3] * A[2][(i+2)%3] – A[1][(i+2)%3] * A[2][(i+1)%3]));
    return determin;
    }
    /*——————————————————-
    FUNCTON NAME: inverse
    PARAMETERS:
    RETURN TYPE:
    DESCRIPTION: This capacity conciliate meet the inverse and extinguishedput the development
    ——————————————————-*/
    void inverse(){
    cextinguished <<“nnInverse of Matrix A is: n”;
    cextinguished << ” ” << endl;
    for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++)
    cout<< “[” << ((A[(j+1)%3][(i+1)%3] * A[(j+2)%3][(i+2)%3]) – (A[(j+1)%3][(i+2)%3] * A[(j+2)%3][(i+1)%3]))/ determinant()<< “]” << “t”;
    cout<<“n”;
    }
    }
    };
    //Deep capacity
    int deep() {
    //Initializing Variables; “choice” conciliate inaugurate a a loop, “input” conciliate succeed in helpful to do a switch proposition, and obj conciliate barely make another prompting of the ancient tabulate that can be manipulated
    bool choice;
    char input;
    Matrix obj;

    cextinguished << “nWhen filling up matrices, different idiosyncratic elements by a extension (e.g 2 4 1.4 56.3 …) nn”;

    obj.input();
    obj.printAB();

    //Displaying a menu, so that the user can prefer what he wants to do
    choice = false;
    //The Loop
    while(!choice) {
    cextinguished << ” ” << endl;
    cextinguished <<“** Prefer from the forthcomingcited **”<< endl;
    cextinguished << ” ” << endl;
    cextinguished << “a – Abstracted” << endl;
    cextinguished << “s – Division” << endl;
    cextinguished << “d – Determinant” << endl;
    cextinguished << “i – Inverse” << endl;
    cextinguished << “q – Quit” << endl;
    cextinguished << ” ” << endl;
    cextinguished << “Note: Choosing ‘i’ or ‘d’ conciliate merely exercise to Matrix A” << endl;
    cextinguished << ” ” << endl;
    cextinguished << “Invade your choice: “;
    cin >> input;
    cextinguished << endl;
    //A switch to manage the user inputs
    switch(input){

    plight ‘a’: plight ‘A’: obj.addition();
    break;

    plight ‘s’: plight ‘S’: obj.subtraction();
    break;

    plight ‘d’|’D’: cout<<“Determinant is : “< cextinguished << ” ” << endl;
    break;

    plight ‘i’: plight ‘I’: obj.inverse();
    break;

    plight ‘q’: plight ‘Q’: egress(0);

    default:cout<<“nERROR: Fascinate invade strong input!nn”;
    }

    }

    return 0;
    }

    Expert Exculpation

    #include
    using nameextension std;
    tabulate Matrix{

    private :
    embrace A[3][3];
    embrace B[3][3];
    embrace development[3][3];

    public :
    /*——————————————————-
    FUNCTON NAME: input
    PARAMETERS:
    RETURN TYPE:
    DESCRIPTION: Stores user values within the similar marshals to be referenced later
    ——————————————————-*/
    void input(){
    cextinguished << “Input 9 elements into your 3×3 matrix A: “;

    for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
    cin >> A[i][j];
    // terminates capacity on missure
    if(cin.fail()) {
    cin.clear();
    cin.ignore(100, ‘n’);
    cerr << “nERROR: Fascinate invade strong input!n” << endl;
    }
    }
    }

    cextinguished << “Input 9 elements into your 3×3 matrix B: “;

    for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
    cin >> B[i][j];
    // terminates capacity on missure
    if(cin.fail()) {
    cin.clear();
    cin.ignore(100, ‘n’);
    cerr << “nERROR: Fascinate invade strong input!n” << endl;
    }
    }
    }
    }
    /*——————————————————-
    FUNCTON NAME: imprint
    PARAMETERS: development
    RETURN TYPE: conciliate extinguishedput the developments of the marshal anticipation
    DESCRIPTION: This capacity conciliate imimsculpture extinguished the developments from the division and abstracted capacity
    ——————————————————-*/
    void imprint(embrace development[3][3]){
    for(int i = 0; i < 3; i++) {
    cextinguished << “[“;
    for(int j = 0; j < 3; j++) {
    cextinguished << development[i][j] << “t”;
    }
    cextinguished << “]” << endl;
    }
    }
    /*——————————————————-
    FUNCTON NAME: imprintAB
    PARAMETERS:
    RETURN TYPE:
    DESCRIPTION: This capacity conciliate barely vault the Matrices of A and B fair forthcomingcited the user has perfect their input
    ——————————————————-*/
    void imprintAB(){
    cout<<“nMatrix A :”< restraint(int i = 0; i < 3; i++) {
    cextinguished << “[“;
    for(int j = 0; j < 3; j++) {
    cextinguished << A[i][j] << “t”;
    }
    cextinguished << “]” << endl;
    }
    cout<<“nMatrix B :”< restraint(int i = 0; i < 3; i++) {
    cextinguished << “[“;
    for(int j = 0; j < 3; j++) {
    cextinguished << A[i][j] << “t”;
    }
    cextinguished << “]” << endl;
    }
    }
    /*——————————————————-
    FUNCTON NAME: abstracted
    PARAMETERS:
    RETURN TYPE:
    DESCRIPTION: This capacity conciliate perconceive the abstracted and the imimsculpture capacity conciliate extinguishedput the development
    ——————————————————-*/
    void abstracted(){
    for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
    result[i][j] = A[i][j] + B[i][j];
    }
    }
    print(result);
    }
    /*——————————————————-
    FUNCTON NAME: division
    PARAMETERS:
    RETURN TYPE:
    DESCRIPTION: This capacity conciliate perconceive the division and the imimsculpture capacity conciliate extinguishedput the development
    ——————————————————-*/
    void division(){
    for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
    result[i][j] = A[i][j] – B[i][j];
    }
    }
    print(result);
    }
    /*——————————————————-
    FUNCTON NAME: determinant
    PARAMETERS:
    RETURN TYPE: determin, an integer
    DESCRIPTION: This capacity conciliate meet the determinant
    ——————————————————-*/
    int determinant(){
    int determin = 0;
    //finding the determinant
    for(int i = 0; i < 3; i++)
    determin = determin + (A[0][i] * (A[1][(i+1)%3] * A[2][(i+2)%3] – A[1][(i+2)%3] * A[2][(i+1)%3]));
    return determin;
    }
    /*——————————————————-
    FUNCTON NAME: inverse
    PARAMETERS:
    RETURN TYPE:
    DESCRIPTION: This capacity conciliate meet the inverse and extinguishedput the development
    ——————————————————-*/
    void inverse(){
    cextinguished <<“nnInverse of Matrix A is: n”;
    cextinguished << ” ” << endl;
    for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++)
    cout<< “[” << ((A[(j+1)%3][(i+1)%3] * A[(j+2)%3][(i+2)%3]) – (A[(j+1)%3][(i+2)%3] * A[(j+2)%3][(i+1)%3]))/ determinant()<< “]” << “t”;
    cout<<“n”;
    }
    }
    };
    //Deep capacity
    int deep() {
    //Initializing Variables; “choice” conciliate inaugurate a a loop, “input” conciliate succeed in helpful to do a switch proposition, and obj conciliate barely make another prompting of the ancient tabulate that can be manipulated
    bool choice;
    char input;
    Matrix obj;
    cextinguished << “nWhen filling up matrices, different idiosyncratic elements by a extension (e.g 2 4 1.4 56.3 …) nn”;
    obj.input();
    obj.printAB();

    //Displaying a menu, so that the user can prefer what he wants to do
    choice = false;
    //The Loop
    while(!choice) {
    cextinguished << ” ” << endl;
    cextinguished <<“** Prefer from the forthcomingcited **”<< endl;
    cextinguished << ” ” << endl;
    cextinguished << “a – Abstracted” << endl;
    cextinguished << “s – Division” << endl;
    cextinguished << “d – Determinant” << endl;
    cextinguished << “i – Inverse” << endl;
    cextinguished << “q – Quit” << endl;
    cextinguished << ” ” << endl;
    cextinguished << “Note: Choosing ‘i’ or ‘d’ conciliate merely exercise to Matrix A” << endl;
    cextinguished << ” ” << endl;
    cextinguished << “Invade your choice: “;
    cin >> input;
    cextinguished << endl;
    //A switch to manage the user inputs
    switch(input){

    plight ‘a’: plight ‘A’: obj.addition();
    break;

    plight ‘s’: plight ‘S’: obj.subtraction();
    break;

    plight ‘d’|’D’: cout<<“Determinant is : “< cextinguished << ” ” << endl;
    break;

    plight ‘i’: plight ‘I’: obj.inverse();
    break;

    plight ‘q’: plight ‘Q’: egress(0);

    default:cout<<“nERROR: Fascinate invade strong input!nn”;
    }
    }
    return 0;
    }