Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Homework Help Create a C++ program as follows: 1. Ask the user for the name

ID: 3792025 • Letter: C

Question

C++ Homework Help

Create a C++ program as follows:

1. Ask the user for the name of a file, read the name of the file from standard input. The first row of the file contains the number of rows and columns in the file. The remainder of the file is expected to contain a matrix of numbers in the form of multiple lines of space or tab delimited numbers. Examples are provided below. For this project, no valid input file shall have more then 20 rows or 20 columns.

2. Read the contents of the file and determine if the matrix of numbers exhibits “vertical additive symmetry”. The definition of this term is provided below.

3. If the matrix of numbers in the file exhibits “vertical additive symmetry”, output “vertical additive symmetry” to standard output. Otherwise, output “no vertical additive symmetry” to standard output.

4. Print each row of the matrix in descending order, one row per line of output, with each number separated by a space.

Definition of vertical additive symmetry: A matrix of numbers is defined to exhibit vertical additive symmetry if the sum of the numbers in the columns of the matrix exhibits vertical symmetry.

Explanation / Answer

1.This piece of code shall help you to perform step 1.

4.For comparing the sum of the columns

for (j=0;j<20;j++)

{

if (c[j]==c[j+1])

{

cout<<"vertical additive symmetry";

}

else

{

cout<<"no vertical additive symmetry";

}

}

  #include <iostream>  #include <fstream>  #include <cstdlib>  #include <string>  using namespace std;    int main()  {            ofstream outClientFile;          string fileName;            cout << "Enter the file name : ";          cin >> fileName;            outClientFile.open(fileName.c_str());            //error checking          if (!outClientFile)          {                  cerr << "File could not be opened." << endl;                  exit(1);          }    2.This code shall help you to read a file and store into a 2-D array                
  void signal::import_data(string filename){      ifstream file;        file.open(filename.c_str());        if(file.fail()){          cerr << "file open fail" << endl;      }else{            
  for(int j = 0; j < NumCols; j++)  {     for(int i = 0; i < NumRows; i++)     {           if ( !(file >> _data[j][i]) )            {               std::cerr << "error while reading file";               break;           }     }     if ( !file ) break;  
      }      file.close();  
   3.The following code shall help you to find sum of columns  // Loop for Column sum   for ( j=0; j<col; j++ )  {   c[j]=0;   for ( i=0; i<row; i++ )   c[j] = c[j] + A[i][j];  }                 return 0;    }  

4.For comparing the sum of the columns

for (j=0;j<20;j++)

{

if (c[j]==c[j+1])

{

cout<<"vertical additive symmetry";

}

else

{

cout<<"no vertical additive symmetry";

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote