When I learned the C language, I suddenly wanted to write a small program to calculate the average performance point of a semester. At that time, I was very excited and felt that there was a collection value. So add it to your favorites! Of course, it is still very general.
# Include <stdio. h>
Void main ()
{
Int I = 0;
Int J = 0;
Int test_lessons = 0;
Int check_lessons = 0;
Char check_level [5];
Float check_credit [20];
Float test_credit [20];
Float check_point [20];
Float test_point [20];
Float total1 = 0.00;
Float total2 = 0.00;
Float total_credit1 = 0.00;
Float total_credit2 = 0.00;
Float test_mark [5];
Printf ("********************************** \ n" );
Printf ("* excellent level corresponds to input a * \ n ");
Printf ("* yield level corresponds to input B * \ n ");
Printf ("* level corresponds to input C * \ n ");
Printf ("* pass level corresponding to input D * \ n ");
Printf ("* The failure level corresponds to the input E * \ n ");
Printf ("********************************** \ n" );
Printf ("Enter the number of tested courses :");
Scanf ("% d", & check_lessons );
Fflush (stdin );
Printf ("Enter all credits for the course :");
For (I = 0; I <check_lessons; I ++)
Scanf ("% F", & check_credit [I]);
Fflush (stdin );
Printf ("Enter the level of the exam :");
For (I = 0; I <check_lessons; I ++)
{Scanf ("% C", & check_level [I]);
If (check_level [I] = 'A' | check_level [I] = 'B' | check_level [I] = 'C' | check_level [I] = = 'D' | check_level [I] = 'E ')
{
Switch (check_level [I])
{
Case 'A ':
Check_point [I] = 8.0;
Break;
Case 'B ':
Check_point [I] = 6.0;
Break;
Case 'C ':
Check_point [I] = 4.0;
Break;
Case 'D ':
Check_point [I] = 2.0;
Break;
Case 'E ':
Check_point [I] = 0.0;
Break;
}
}
Else printf ("input error! Enter again! ");
Total1 + = check_point [I] * check_credit [I];
Total_credit1 + = check_credit [I];
}
Fflush (stdin );
Printf ("Enter the number of test courses :");
Scanf ("% d", & test_lessons );
Fflush (stdin );
Printf ("Enter all exam scores :");
For (j = 0; j <test_lessons; j ++)
Scanf ("% F", & test_mark [J]);
Fflush (stdin );
Printf ("Enter credits for all test courses :");
For (j = 0; j <test_lessons; j ++)
{
Scanf ("% F", & test_credit [J]);
If (test_mark [J] <= 60)
Test_point [J] = 0.0;
Else
Test_point [J] = (test_mark [J]-50) * 0.2;
Total2 + = test_point [J] * test_credit [J];
Total_credit2 + = test_credit [J];
}
// Test calculation
Printf ("\ n your average credits are: %. 5f \ n", (total1 + total2)/(total_credit1 + total_credit2 )));
If (total1 + total2)/(total_credit1 + total_credit2)> = 6.0)
{
Printf ("************************************* * ********** \ n ");
Printf ("* Congratulations! You have won scholarship! * \ N ");
Printf ("************************************* * ********** \ n ");
}
Else
Printf ("\ nwork hard and you will win scholarship next time. \ n ");
Fflush (stdin );
Getchar ();
}
I will continue to work hard in the future!