Write a program that reads from the keyboard, the number of point scored by the football team in each game. In the meantime, it also writes the entered scores into a file - scores.txt.
To begin with, the user doesn’t know the number of games played during the last season, hence, the agreed sentinel value between the user and the programmer is 7777. The program should stop reading the user’s input when a sentinel value is entered. Now, the program reads back the scores from the file, prints all the scores, prints the total number of points scored in the last season, and prints the average number of points scored (2 decimal points).
This is my assignment and i have no idea where to start
#include <iostream>
#include <fstream>
usingnamespace std;
int main()
{
int game=1;
int points=0;
int total, average;
ofstream outfile;
ifstream infile;
outfile.open("aggiescores.txt");
while(points != 7777);
{
cout<<"Enter the number of points scored in Game "<<game<<":"<<endl;
cout<<"Enter 7777 when you are done";
cin>>points;
outfile<<points;
cout<<"Scores written into file …. aggiescores.txt";
game++;
}
outfile.close();
infile.open("aggiescores.txt");
while ( infile >> points);
{
cout<<"Reading scores…";
cout<<"Following are the scores from each game: "<<endl;
cout<<points<<endl;
}
infile.close();
cout<<"Aggies scored a total of "<<total<<" from "<<game<<" games and averaged at "<<average<<" points per game.";
return 0;
}