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

Please help with the following problem using Visual Studio. Write a program that

ID: 3860725 • Letter: P

Question

Please help with the following problem using Visual Studio.

Write a program that reads a file containing two columns of floating-point numbers. Prompt the user for the file name. Print the average of each column.

Directions:
1. Please create a file that contains 10 sets of a pair of two floating numbers.
2. Then, your program should get the file name entered by a user and subsequently input these 10 sets of record from the file and produces a report showing a table containing 2 columns and an average of each
column.
Note: Please print the table that the program produced. By the way, each column should have a title.

Explanation / Answer

#include<bits/stdc++.h>
using namespace std;

using namespace std;

int main(int argc, char * argv[])
{
//std::fstream myfile("notes.txt", std::ios_base::in);

float a = 0;
float b = 0;
float sumA=0,sumB=0;
ifstream infile;
infile.open("notes.txt");
infile>>a>>b;
for (int i = 0; i < 10; ++i)
{
  

infile>>a>>b;
cout<<a<< " "<<b<<endl;
sumA+=a;
sumB+=b;
}

cout<<"Average is "<<(sumA/10)<<" "<<(sumB/10)<<endl;

return 0;
}