Code:
#include<stdio.h>
main()
{
int e,gamesPlayed,won,lost;
float wuTot,oppTot,spreadTot,spread,wuScore,oppScore;
float wuAvg,oppAvg,spreadAvg,date;
FILE *payInFile, *payOutFile;
payInFile = fopen("dataS.txt","r");
payOutFile = fopen("outS.txt","w");
fprintf(payOutFile, "Bradley Lantz Project 2 Due 10/6/11");
fprintf(payOutFile, "CM111 Barker\n\n");
fprintf(payOutFile, "WU Football '10 Statistics\n");
fprintf(payOutFile, "WU OPP SPREAD\n");
wuTot=0;
oppTot=0;
spreadTot=0;
gamesPlayed=0;
won=0;
lost=0;
e=fscanf(payInFile, "%f %f", &wuScore, &oppScore);
while (e==2)
{
wuTot=wuTot+wuScore;
oppTot=oppTot+oppScore;
if (wuScore > oppScore)
{
won=won+1;
}
else
{
lost=lost+1;
}
spread=wuScore-oppScore;
spreadTot=spreadTot+spread;
gamesPlayed=gamesPlayed+1;
fprintf(payOutFile, "%2.0f %5.0f %5.0f\n", wuScore, oppScore, spread);
e=fscanf(payInFile, "%f %f", &wuScore, &oppScore);
}
spreadAvg=spreadTot/gamesPlayed;
wuAvg=wuTot/gamesPlayed;
oppAvg=oppTot/gamesPlayed;
fprintf(payOutFile, " ");
fprintf(payOutFile, "WU OPP SPREAD\n");
fprintf(payOutFile, " Totals for season to date:");
fprintf(payOutFile, "%5.0f %8.0f %9.0f\n", wuTot, oppTot, spread);
fprintf(payOutFile, "Averages for season to date:");
fprintf(payOutFile, "%7.2f %9.2f %9.2f\n", wuAvg, oppAvg, spreadAvg);
fprintf(payOutFile, "WU Football's Current Record is ");
fprintf(payOutFile, "%d", won);
fprintf(payOutFile, " - ");
fprintf(payOutFile, "%d", lost);
}
If anybody can help me figure it out that would be appreciated. Thanks!!!