1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Korolek [52]
2 years ago
5

Obtain a file name from the user, which will contain data pertaining to a 2D array Create a file for each of the following: aver

ages.txt : contains the overall average of the entire array, then the average of each row reverse.txt : contains the original values but each row is reversed flipped.txt : contains the original values but is flipped top to bottom (first row is now the last row etc.) If the dimensions of array are symmetric (NxN), create a diagonal.txt: contains the array mirrored on the diagonal
Computers and Technology
1 answer:
cricket20 [7]2 years ago
7 0

Answer:

see explaination

Explanation:

#include <iostream>

#include <fstream>

#include <iomanip>

using namespace std;

int main()

{

string filename, file1, file2, file3, file4;

cout << "Enter the filename : ";

getline(cin, filename);

int row, col;

ifstream ifile;

ifile.open(filename.c_str());

if(!ifile)

{

cout << "File does not exist." << endl;

}

else

{

ifile >> row >> col;

float mat[row][col], diag[row][col];

for(int i=0; i<row; i++)

{

for(int j=0; j<col; j++)

ifile >> mat[i][j];

}

cout << "Enter the filename to save averages : ";

getline(cin, file1);

ofstream avgFile(file1.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);

float t_avg = 0, avg = 0;

for(int i=0; i<row; i++)

{

avg = 0;

for(int j=0; j<col; j++)

{

avg += mat[i][j];

}

t_avg += avg;

avg = avg/col;

avgFile << std::fixed << std::setprecision(1) << "Row " << i+1 << " average: " << avg << endl;

}

t_avg = t_avg / (row*col);

avgFile << std::fixed << std::setprecision(1) << "Total average: " << t_avg << endl;

cout << "Enter the filename to store reverse matrix : ";

getline(cin, file2);

ofstream revFile(file2.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);

for(int i=0; i<row; i++)

{

for(int j=col-1; j>=0; j--)

{

revFile << std::fixed << std::setprecision(1) << mat[i][j] << " ";

}

revFile << endl;

}

cout << "Enter the filename to store flipped matrix : ";

getline(cin, file3);

ofstream flipFile(file3.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);

for(int i=row-1; i>=0; i--)

{

for(int j=0; j<col; j++)

{

flipFile << std::fixed << std::setprecision(1) << mat[i][j] << " ";

}

flipFile << endl;

}

cout << "Enter the filename to store diagonal matrix : ";

getline(cin, file4);

ofstream diagFile(file4.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);

for(int i=0; i<row; i++)

{

for(int j=0; j<col; j++)

{

diag[j][i] = mat[i][j];

}

}

for(int i=0; i<col; i++)

{

for(int j=0; j<row; j++)

{

diagFile << std::fixed << std::setprecision(1) << diag[i][j] << " ";

}

diagFile << endl;

}

}

return 0;

}

You might be interested in
You are developing a Windows forms application used by a government agency. You need to develop a distinct user interface elemen
-BARSIC- [3]

Answer:

The answer is "Developing the custom control for the user interface"

Explanation:

The major difference between customized control & user control would be that it inherit throughout the inheritance tree at different levels. Usually, a custom power comes from the system. Windows. UserControl is a system inheritance.

Using accuracy up is the major reason for designing a custom UI control. Developers must know how to use the API alone without reading the code for your component. All public methods and features of a custom control will be included in your API.

6 0
2 years ago
The function below takes a single parameter number_list which is a list that can contain integers and floats. Complete the funct
Andreas93 [3]

Answer:

  1. def getLargest(number_list):
  2.    new_list = []
  3.    for x in number_list:
  4.        if(isinstance(x, int)):
  5.            new_list.append(x)
  6.    largest = max(new_list)
  7.    return largest  

Explanation:

Firstly, create a function <em>getLargest()</em> that take one input parameter, <em>number_list</em>.

The function will filter out the float type number from the list by using <em>isinstance() </em>method (Line 5). This method will check if a current x value is an integer. If so, the x value will be added to <em>new_list</em>.

Next, use Python built-in <em>max</em> function to get the largest integer from the <em>new_list </em>and return it as output.

6 0
3 years ago
Hurry plz
Elanso [62]

Answer: It allows you to locate materials, be aware of your assignments and plan time to get things done.

Hope it helped.

3 0
3 years ago
A computer program that enables users to create and work with files and folders is called what?
murzikaleks [220]

Answer:

File manager

Explanation:

From the list of options 1 to 4, only option (2) is correct

Explaining the options one after the other

  • Web browser: It lets users access the internet
  • File Manager: Used to create and manage files/folders
  • User Interface: Means which the user of a computer interacts with the computer
  • File Reader: Used to read the content of a file. e.g. Adobe reader for pdf files, Notepad for text files, etc.

Having explained the options one after the other, <em>the file manager </em>is the answer to this question.

3 0
2 years ago
Read 2 more answers
What is a neuromorphic chip?
Dominik [7]

Answer:

A neuromorphic computer is a machine comprising many simple processors / memory structures (e.g. neurons and synapses) communicating using simple messages (e.g. spikes). ... Neuromorphic computing systems excel at computing complex dynamics using a small set of computational primitives (neurons, synapses, spikes).

Explanation:

The structure of neuromorphic computers makes them much more efficient at training and running neural networks. They can run AI models at a faster speed than equivalent CPUs and GPUs while consuming less power. This is important since power consumption is already one of AI's essential challenges.

3 0
3 years ago
Other questions:
  • Ming is building an inexpensive computer to use for her online classes, and needs to purchase Windows. What is the most cost-eff
    8·1 answer
  • A(n) ____________________ or cryptosystem is an encryption method or process encompassing the algorithm, key(s) or cryptovariabl
    11·1 answer
  • In a paragraph of no less than 125 words, describe how technology helps business professionals to be more efficient. Include exa
    12·2 answers
  • How can I sent a message?
    13·1 answer
  • I would A lot of knowledge and education for computers and <br> Technology
    10·2 answers
  • This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by
    8·1 answer
  • ____ is the process of drawing a series of increasingly detailed DFDs, until all functional primitives are identified.
    7·1 answer
  • How to program a game​
    7·2 answers
  • In C!!
    11·1 answer
  • In 1980, IBM's cheapest computer was more affordable than Apple's.<br><br><br> True<br><br> False
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!