Thursday, March 19, 2009

exer5





#include
#include
#define cp cprintf
#define s scanffloat grade, average, items, sum;
void main()
{
clrscr();
average=0;sum=0;
do
{
textcolor(YELLOW);
cp("Enter grade (-1 to exit): ");
s("%f", &grade);
if((grade!=-1)&&(grade<=100)) { items++; sum=sum+grade; }} while(grade!=-1);average=sum/items;textcolor(GREEN); cp("Class Average: %.2f\n", average); if((average>=95)&&(average<=100)) { textcolor(GREEN);cp("Rating: A"); } else if ( (average>=90)&&(average<=94)) {textcolor(GREEN); cp("Rating: B"); } else if((average>=85)&&(average<=89)) { textcolor(GREEN);cp("Rating: C"); } else if((average>=80)&&(average<=84)) { textcolor(GREEN);cp("Rating: D"); } else if((average>=75)&&(average<=79)) { textcolor(GREEN);cp("Rating: E"); } else if(average<=74) { textcolor(GREEN);cp("Rating: FAILED"); } getch(); }

No comments:

Post a Comment