Okay so i am really new to coding(about 2 weeks) and need help with an assignment.the asignment goes like this
"Write a program that will read in a file named pa7-temp.txt (located in the current directory) that contains a set of temperatures, and then prints out how many were in the file and the average temperature. This program must read the input data in one line at a time as strings.
The output should look like this (with XX and YY.YYYY being replaced with correct numbers):
There were XX days of temperature data and the average temperature was YY.YYYY."
Yes i know i have unused variables but i'm pretty sure i need them i just not sure how to implement them how i need.
This is what i have so far(and it's not much)
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
int days;
string line;
int count;
ifstream inFile("pa7-temp.txt", ios::in);
if (!inFile)
{
cerr << "File could not be opened" << endl;
exit(1);
}
while (inFile.peek() != EOF)
{
getline(inFile, line);
cout << line;
}
cout << "There were" << days <<" days of temperature data & the average"
<< " temperature was" << days/count << "." << endl;
}