السلام عليكم ...
طلب منا الاستاذ هذا البروجكت..
Write a C program to read results of class of 20 students. Each student has 4 results, distributed as follow:
• Test 1 25 %
• Test 2 25 %
• Test 3 25 %
• Final 50 %
The program should do the following tasks
1- Read the 4 results of each student.
2- Store the results in separated single dimensional arrays.
3- Create new array Average; which contains the average of each student. (see point 4)
4- The average of student is determined by user-defined function named as calculate_average; which receives the four results and returns the average of the - final and the highest two tests only- (drop the lowest test).
5- Create a new array Grades; which contains the equivalent grade letter for each student. (see point 6)
6- The grade letter must be determined using a user-defined function named as grade_letter that receives the average of each student and returns the corresponding letter based on the following categories.
100 – 90 is A
89 – 80 is B
79 – 70 is C
69 – 60 is D
59 – 0 is F
وهذه محاولتي لحل أول جزء من الكود لكني لم أوفق !!
فأتمنى منكم مساعدتي لأعرف ما هو الخطأ في if statment
#include<stdio.h>
#define STUDENTS 2
int
main()
{
double test1,test2, test3, test4;
int student_num=1;
while(student_num <= STUDENTS)
{
printf("enter the score for student %d\n",student_num);
printf("enter the score in test 1>> ");
scanf("%lf",&test1);
printf("enter the score in test 2>> ");
scanf("%lf",&test2);
printf("enter the score in test 3>> ");
scanf("%lf",&test3);
printf("enter the score in test 4>> ");
scanf("%lf",&test4);
printf("\n\n");
student_num=student_num+1;
if (test1<0 || test1>25 || test2<0 || test2>25 || test3<0 || test3>25 || test4<0 || test4>50 ){
printf("invaled value\n");
printf("enter the scoer again\n");
printf("enter the score for student %d\n",student_num);
printf("enter the score in test 1>> ");
scanf("%lf",&test1);
printf("enter the score in test 2>> ");
scanf("%lf",&test2);
printf("enter the score in test 3>> ");
scanf("%lf",&test3);
printf("enter the score in test 4>> ");
scanf("%lf",&test4);
printf("\n\n");}
else
printf("go to next student");
}
return (0);
}وإذا عندكم أي ملاحظات أو hints تمكنني من استكمال كتابة الكود سأكون شاكرة لكم...
شكــــراً جزيلاً مقدماً