This is a discussion on Helpful hints anyone? within the C Programming forums, part of the General Programming Boards category; Does anyone know how to complete this problem from my code that I have provided? I know it might not ...

Does anyone know how to complete this problem from my code that I have provided? I know it might not be allowed to post answers on this forum, but any pointers would be helpful, espeically regarding the section where it says "Only if the grade needs to be determined between D and F, allow the user to enter the number of homework assignments the student turned in, and the total number of homework assignments. If more than 80% of the homework assignments were turned in, the letter grade is D, otherwise F."

Here's the problem:

Write a program that determines a student's letter grade. Allow the user to enter three test scores. The maximum score on each test is 100 points. Determine the letter grade from the average of the test scores, using the following:

* 90% or more A
* 80% or more, but less than 90% B
* 70% or more, but less than 80% C
* 60% or more, but less than 70% D or F, to be determined from additional information
* less than 60% F

Only if the grade needs to be determined between D and F, allow the user to enter the number of homework assignments the student turned in, and the total number of homework assignments. If more than 80% of the homework assignments were turned in, the letter grade is D, otherwise F.

Test it 4 times:

* 96 84 90
* 95 83 90
* 70 59 60 with 4 homework out of 5 turned in
* 73 58 65 with 8 homework out of 11 turned in
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;

// Statements
printf("Enter three test scores (0-100): ");
scanf("%d", &score, &score2, &score3);

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 temp;

//Statements
temp = score / 10;
switch (temp)
{
case 10:
case 9 : grade = 'A';
break;
case 8 : grade = 'B';
break;
case 7 : grade = 'C';
break;
case 6 : grade = 'D';
break;
}
}```
Thank you kindly.

2. It says that getting a D has additional criteria. You have to change the grade to F if they missed more than 20% of their homework.

That's just yet another percentage:

Code:
```get homework completed
get homework assigned

if homework completed / homework assigned  < .80
I used real numbers but you could probably do it with integers if you wanted.

3. How would I implement that bit of code into the program to make it work? Sorry for not understanding.

4. Sorry, I didn't write compilable C code. I think you know enough to take what I showed you as an example and write it out. If they could get a D, then compute the percentage, and decide if they get an F. I don't see a problem putting the actual code under the D grade case in your switch.

5. Using whiteflags' pseudo code:
Code:
```            case 6 :
get homework completed (get an integer from the user)
get homework assigned (get another integer from the user)
if homework completed / homework assigned  < .80
else
break;```
Also, you need to ask for all 3 scores, so you need 3 format specifiers for the scores you collect in main:
Code:
```    // Statements
printf("Enter three test scores (0-100): ");
scanf("%d %d %d", &score, &score2, &score3);```

6. 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;

// Statements
printf("Enter three test scores (0-100): ");
scanf("%d %d %d", &score, &score2, &score3);

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 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)