Thanks for your help guys. Everything works now except for the fact that when the program is run, it automatically prints the default grade when any three grades are entered. Help on this?
Code:
#include <stdio.h>
// Function Declarations
char scoreToGrade (int score, int score2, int score3);
int main (void)
{
// Local Declarations
int score;
int score2;
int score3;
char grade;
// Statements
printf("Enter three test scores (0-100): ");
scanf("%d %d %d", &score, &score2, &score3);
grade = scoreToGrade (score, score2, score3);
printf("The grade is: %c\n", grade);
int temp;
printf("Enter an integer and press Enter to exit the program: ");
scanf("%d", &temp);
return 0;
}
char scoreToGrade (int score, int score2, int score3)
{
// Local Declarations
char grade;
char temp;
int homework_completed;
int homework_assigned;
//Statements
temp = (score + score2 + score3) / 10;
switch (temp)
{
case 10:
case 9 : grade = 'A';
break;
case 8 : grade = 'B';
break;
case 7 : grade = 'C';
break;
case 6 : printf("Enter the number of homework assignments assigned: \n");
scanf("%d", &homework_assigned);
printf("Enter the number of homeowrk assignments completed: \n");
scanf("%d", &homework_completed);
if (homework_completed / homework_assigned > .80)
grade = 'D';
else
grade = 'F';
break;
default: grade = 'F';
}
return grade;
}