Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I'm working on a lab and I can't figure it out. Here is my main: int main() { ifstream infile; ofstream outfile; infile.open(sp05AveragesData.txt); outfile.open(spRepetitionAverages.txt);

Hi, I'm working on a lab and I can't figure it out.

Here is my main:

int main() {

ifstream infile;

ofstream outfile;

infile.open("sp05AveragesData.txt");

outfile.open("spRepetitionAverages.txt");

if (!infile){

cout << "File failed to open.";

} else {

string lineNumbers;

while (std::getline(infile, lineNumbers)) {

cout << lineNumbers << endl;

}

}

return 0;

}

I'm reading data from a file, and I need to get the average of each line in the file and send that average to another file.

This is the data in the file I'm reading from:

5 5.7 8.7 4.9 6.72 6.41 9 2.1 1.99 2.01 1.8734 1.746 1.914 2.00345 1.70 1.69 3 28.4323345 28.499234 28.432451 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago