//Program to calculate average test score
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
using namespace std;
int main()
{
//Declare variables; Step 1
ifstream inFile;
ofstream outFile;
int test1,test2,test3,test4,test5;
double average;
char studentId;
inFile.open("i:text.txt");
outFile.open("i:testavg.out");
outFile<<setiosflags(ios::fixed);
outFile<<setiosflags(ios::showpoint);
outFile<<setprecision(2);
cout<<"Processing data"<<endl;
inFile>>studentId;
outFile<<"Student ID: "<<studentId<<endl;
inFile>>test1>>test2>>test3
>>test4>>test5;
outFile<<"Test scores: "<<setw(4)<<test1
<<setw(4)<<test2<<setw(4)<<test3
<<setw(4)<<test4<<setw(4)<<test5
<<endl;
average = static_cast<double>(test1 + test2 + test3 + test4 + test5) / 5.0;
outFile<<"Average test score: "<<setw(6)
<<average<<endl;
inFile.close();
outFile.close();
return 0;
}
这个是一个输入分数求平均成绩的程序
我运行的时候屏幕上只有Processing data,然后就结束程序了
这是怎么回事啊