Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that predicts the score needed on a final exam to achieve a desi

ID: 3878083 • Letter: W

Question

Write a program that predicts the score needed on a final exam to achieve a desired grade in a course. The program should interact with the user as follows: Enter desired grade> B Enter minimum average required> 79.5 Enter current average in course> 74.6 Enter how much the final counts as a percentage of the course grade> 25 You need a score of 94.20 on the final to get a

In c++, i am writing a program to calcualte the required grade on a final to get a specific grade in the couarse. however, the input of the specific grade is supposed to be a letter grade, how do i convert an input charchter like "A+ or C-" to a double that can be used in equations? (lets say A+=94 and C-=70)

here is my current code that calulates number inputs, i need it to ask the user for a character that is equal to a double that can be used

#include<stdio.h>

int

main(void)

{

char key;

double g, gm, gc, f, x, y, z;

printf("type in desired grade ");

scanf("%lf", &g);

printf("type in minimum grade required (percentage) ");

scanf("%lf", &gm);

printf("type in current average " );

scanf("%lf", &gc);

printf("type in percentage final is worth ");

scanf("%lf", &f);

y=g-gc;

z=y/f;

x=z*100;

  

printf("the minimun required grade to get a %f",g);

printf("is %f ", x);

printf(" ");

printf("Enter any key to leave: ");

scanf(" %c", &key);

return (0);

}

Explanation / Answer

You need to store the double value for the corresponding grade somewhere. An ideal way is to use a map but since the code is in C and there are not many in built functionalities, i would suggest using two 1-d arrays , char* grade[] and double percentage[] where i-th grade in the grade[] array would have i-th percentage. For example for A+=94, B+=80,C=70, grade would have the strings, A+, B+ ,C and percentage would have 94,80,70.

converting grade to percentage: Let N be the size of the grade and percentage arrays

double convert(char *inpGrade){
for(int i=0;i<N;i++){
if(strcmp(inpGrade, grade[i])==0)
return percentage[i];
}
return -1;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote