i am at a loss as to how to go about adding this modification to the below program.

need the prog. ask the user to enter midterm,final and weight for a student, to ask whether or not they are taking it Pass/Fail or for a grade.. should allow the user to enter a P (pass/fail) or G (grade)

#include <stdio.h>
char grade (int exam1, int exam2, float exam1_weight );
main ()
int ans, mid_term, final;
float weight;
char letter_grade;
do {
printf(“\n\nCompute another grade (1 = Yes, 0 =No)? ”);
scanf(“%d”, &ans);
if (ans == 1) {
printf( “\nEnter mid_term, final, weight: “);
scanf(“%d%d%f”, &mid_term, &final, &weight );
letter_grade = grade(mid_term, final, weight);
printf(“Grade is: %c\n”, letter_grade);
} while (ans == 1);
char grade (int exam1, int exam2, float exam1_weight)
float average;

average = exam1_weight * exam1 + (1.0 – exam1_weight) * exam2;
if (average > 7.0)
return ‘P’;
return ‘F’;