1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include <stdio.h>
int AllGrades(int homework, int midterm, int final);
int gradeOutput();
int main()
{
int homework, midterm, final;
printf("Input the homework, midterm, and final grade:");
scanf("%d %d %d", &homework, &midterm, &final);
printf("Final exam was %d out of 100 \n", final);
printf("Midterm exam was %d out of 75 \n", midterm);
printf("Homework assignments were %d out of 120 \n", homework);
AllGrades(homework, midterm, final);
gradeOutput();
return 0;
}
int AllGrades(int homework, int midterm, int final)
{
int grade;
if (homework <= 120) {
homework = (homework * 50) / 120;
}
else {
printf("Input error\n");
return 0;
}
if (midterm <= 75) {
midterm = (midterm * 20) / 75;
}
else {
printf("Input error\n");
return 0;
}
if (final <= 100){
final = (final * 30) / 100;
}
else {
printf("Input error\n");
return 0;
}
return 0;
}
int gradeOutput()
{
int homework, midterm, final;
int grade = homework + midterm + final;
printf("Grade is %d\n", grade);
return 0;
}
|