Question
Please help me with C programming in simple way.
Thanks.
The previous one is from 6th edition. This is the same problem with name and number changed from 7th edition. Please help me with this. I just updated.
"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 letter grade> B
Enter minimum average require to achieve that grade> 79.5
Enter current average in course> 74.5
Enter how much the final counts as a percentage of the course grade> 25
You need a score of a 94.20 on the final to get a B."
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> A Enter minimum average required> 95.0 Enter/current average in course> 85.0 Enter how much the final counts as a percentage of the course grade> 10 You need a score of 93.50 on the final to get an A.
Explanation / Answer
#include /* The header file stdio.h contains information about standard input and output functions such as scanf and printf */ int /* integer; indicates the the main function returns an integer value */ main(void) /* void indicates that the main function receives no data from the operating system */ { char grade; /* grade as a letter */ double min_ave; /* minimal average as decimal */ double cur_ave; /* current average as decimal */ int percent; /* percentage as integer */ double ax; /* minimal average minus the current average */ double bx; /* percentage divided by 100 */ double score; /* score as a decimal */ /* Get the desired grade as a letter */ printf("Enter desired grade> "); scanf("%c", &grade); /* Get the minimal average required in the course */ printf("Enter minimal average required> "); scanf("%lf", &min_ave); /* Get the current average in the course */ printf("Enter current average in course> "); scanf("%lf", &cur_ave); /* Get the percentage in which the final counts towards the course grade */ printf("Enter how much the final counts as a percentage of the course grade> "); scanf("%d", &percent); /* Calculate the score needed to receive a grade of B */ ax = min_ave - cur_ave; bx = percent / 100.0; score = (ax / bx) + cur_ave; /* Display the score needed on the final to get the desired grade */ printf("You need a score of %5.2f on the final to get a %c. ", score, grade); return (0); /* return controls from the main function to the operating system */ }