//marks-manage
//zhangsisi_04_14
#include <iostream.h>
#include <stdlib.h>
#include <fstream.h>
enum marks_tag { PERFECT = 1, GOOD, GENERAL, UNMARKS };
bool perfectstate( float, float, float );
bool goodstate( float, float, float );
bool generalstate( float, float, float );
bool badstate( float, float, float );
int getStatement( float, float, float );
void showstatement(int);
int main()
{
ofstream outFile( "marks.txt");
if( !outFile ) {
cerr << "can't init." << endl;
exit( 1 );
}
char name[ 30 ];
long code;
float english_mark;
float maths_mark;
float computer_mark;
int statement;
outFile << "name" << ' ' << "code" << ' ' << "english" << ' '
<< "maths" << ' ' << "computer" << ' ' << "statement" << endl;
cout << " 输入信息: " << endl;
while ( cin >> name >> code >> english_mark >> maths_mark >> computer_mark )
{
statement = getStatement( english_mark, maths_mark, computer_mark );
outFile << name << ' ' << code << ' ' << english_mark
<< ' ' << maths_mark << ' ' << computer_mark << endl;
showstatement( statement );
cout << "continue: " << endl;
}
return 0;
}
bool perfectstate( float eng, float math, float comp )
{
if( eng >= 90 && math >= 90 && comp >= 90 )
return true;
return false;
}
bool goodstate( float eng, float math, float comp )
{
if( eng >= 90 && math >= 90 && comp >= 80 && comp < 90 )
return true;
if( eng >= 90 && math >= 80 && math < 90 && comp >= 90 )
return true;
if( eng < 90 && eng >= 80 && math >= 90 && comp >= 90 )
return true;
return false;
}
bool generalstate( float eng, float math, float comp )
{
if( eng >= 90 && math >= 80 && math < 90 && comp >= 80 && comp < 90 )
return true;
if( eng >=80 && eng < 90 && math >= 90 && comp >= 80 && comp < 90 )
return true;
if( eng >= 80 && eng < 90 && math >= 80 && math < 90 && comp >= 90 )
return true;
return false;
}
bool badstate( float eng, float math, float comp )
{
bool perfectstate( float, float, float );
bool goodstate( float, float, float );
bool generalstate( float, float, float );
if( !( perfectstate( eng, math, comp ) ) )
;
else return false;
if( !( goodstate( eng, math, comp ) ) )
;
else return false;
if( !( generalstate( eng, math, comp ) ) )
;
else return false;
return true;
}
int getStatement( float eng, float math, float comp )
{
bool perfectstate( float, float, float );
bool goodstate( float, float, float );
bool generalstate( float, float, float );
bool badstate( float, float, float );
int statement;
if( perfectstate( eng, math, comp ) )
statement = 1;
if( goodstate( eng, math, comp ) )
statement = 2;
if( generalstate( eng, math, comp ) )
statement = 3;
if( badstate( eng, math, comp ) )
statement = 4;
return statement;
}
void showstatement(int st)
{
ofstream outFile1( "marks.txt", ios::nocreate | ios::ate );
if( !outFile1 ) {
cerr << "can't init." << endl;
exit( 1 );
}
switch (st) {
case PERFECT:
outFile1 << "perfect" << endl;
break;
case GOOD:
outFile1 << "good" << endl;
break;
case GENERAL:
outFile1 << "general" << endl;
break;
case UNMARKS:
outFile1 << "unmarks" << endl;
break;
}
}